Struct Layout

Calculate offsets & total size for C-like structs (packet layout helper).
Supports common types (u8/u16/u32/u64, int*, char, bool, float/double). Arrays supported.

Input (C-like)

Tip: You can omit 'struct X { }' wrapper and just paste fields.

Layout

Field Type Count Size Align Offset Notes
Paste a struct to see results.

FAQ

Why does struct size include padding?

Compilers align fields for efficient access. Padding bytes can be inserted between fields and at struct end.

Does pack(1) always help?

It can reduce size but may hurt performance and can cause unaligned access issues on some targets.

Related tools

HEX ⇄ ASCII ⇄ Binary · CRC Calculator