Binary Protocol Designer
Design a small binary packet from explicit fields. The tool places bits in order, inserts zero bits when you request byte alignment, and shows the exact hex bytes and field offsets. Paste a same-length hex packet to decode values through the same layout. It runs in your browser and does not connect to a device.
Key features
- Pack 1–32-bit unsigned or two's-complement signed integers, including fields that cross byte boundaries
- Set per-field big-endian or little-endian byte order; little-endian requires byte alignment and a whole-byte width
- Request zero-filled byte alignment before any field and inspect bit and byte offsets
- Decode a packet using the current layout, checking exact length and all padding bits
- Download the editable layout JSON, packet hex text and a decoded field report
How to use
- Load the example layout or paste a local-binary-layout-v1 JSON definition and apply it.
- Review field widths, signedness, byte order and optional byte alignment; edit decimal values in the table.
- Encode the layout to produce packet hex and bit/byte offsets.
- Paste or change same-length packet hex and decode it through the layout.
- Download the layout, packet bytes as hex text or the field report.
Use cases
- Check a packed version/flags header followed by a little-endian length field
- Verify signed telemetry deltas crossing a byte boundary
- Explain exactly where each field starts when reviewing a device protocol draft
Frequently asked questions
What is the bit order for packed fields?
Big-endian fields are written most-significant bit first into the packet, with bit 0 at the high bit of byte 0. This also applies when a field crosses a byte boundary.
When can I select little-endian?
Only for fields whose start offset and width are both multiples of 8. Their bytes are stored least-significant first. Use alignBefore=byte when a preceding bit field leaves an unaligned offset.
How are negative values represented?
Signed fields use two's complement at the selected width. For example, a signed 12-bit -17 is encoded as 0xFEF across its 12-bit range; values outside the exact signed range are rejected.
Are padding bits ignored during decoding?
No. Requested alignment gaps and unused bits at the end of the last byte must be zero. Nonzero padding yields an error with the bit position.
What packet sizes are supported?
This version accepts 1–64 fields, each 1–32 bits, with at most 2,048 used bits (256 bytes). The JSON layout is limited to 64 KiB. It does not implement checksums, floating-point formats or a live serial connection.
Does decoding use the decimal values in the layout?
The layout supplies field widths, order and alignment. Decoded values replace the displayed decimal inputs after a successful decode; the input hex must have the exact packet length.
Privacy
Packet layouts and hex values are processed in your browser. This tool does not contact a device or upload your packet.
Comments & questions