C struct decoder.
Paste HEX and a declaration. Inspect the fields. Adjust the layout.
01Input
HEX is formatted as uppercase byte pairs as you edit. Non-HEX characters are ignored; 0x prefixes are accepted.
2 bytes · limit 64 KiB
Paste declarations from a header or stdin. Recognizes struct, typedef, common scalar types, pointers, and fixed arrays. Editing C rebuilds the field list and clears manual edits.
02Settings
SIZE / ALIGN / ORDERAbsolute byte offset, decimal or 0x HEX. Field offsets below are relative to this start.
Text appears beside the numeric value. Trailing NUL padding is accepted; other control or binary bytes keep the numeric view.
All four presets use a 32-bit int. For a target with a different int width, set its byte width in the field editor.
Field layout · editable
Blank byte widths and offsets use automatic values. Width is per element; total bytes = width × count. Offsets accept decimal or 0x HEX. Edits update values immediately and survive HEX/settings changes. Manual mode makes the C input read-only.
| Field name | Live value | Interpretation | Byte width | Count | Struct offset | Total / alignment | Remove field |
|---|
Parse a C definition or add manual fields.
Reading a struct from bytes
HELP / EXAMPLES
For 01 FF and two uint8_t fields, val1 = 1 and val2 = 255. Fixed-width integer types stay exact through 64 bits.
A packed uint8_t followed by uint32_t uses offsets 0 and 1. Natural 4-byte alignment uses offsets 0 and 4, adding padding. Byte order is a separate setting.
Common __attribute__((packed)), __packed, and #pragma pack annotations are recognized. Target presets assume 8-bit bytes, common C type widths, and IEEE binary16/32/64 floating point; plain char is displayed as a character byte. All current presets use a 32-bit int; other targets may require manual widths.
Character arrays are read as text up to the first NUL. Printable uint8_t fields also have a text preview and Copy text button; their numeric values remain available. Arrays of numbers are shown in storage order. Unknown types need a manual interpretation or width. Nested aggregates remain opaque; bit-fields, unions, function-pointer declarations, flexible arrays, and a full C preprocessor are outside automatic parsing.
Use the field editor for custom packet layouts. Manual offsets can overlap; overlaps are flagged. Input and layout limits are 64 KiB, 32 KiB of C text, 256 fields, and 1,024 elements per array. Check a compiler’s sizeof and offsetof for its exact ABI and flags.