Diagrams / Mermaid Packet Diagram: Syntax & Examples

Mermaid Packet Diagram: Syntax & Examples

Document bit fields with Mermaid packet syntax. Edit a header example, check ranges and units, and distinguish a format diagram from packet analysis.

When to use Packet Diagram

Show the bit layout of a structured message with a Mermaid packet diagram. Define field ranges and labels to explain a header or a compact binary record. This documents a format; it does not capture network traffic or decode a packet file.

Read the Packet Diagram example

Diagram source

packet-beta
  0-15: "Message ID"
  16-23: "Version"
  24-31: "Flags"
  32-63: "Payload length"
The example uses labeled bit ranges to separate an identifier, flags, and a payload length. The numbers refer to bit positions, not byte offsets; a 16-bit range occupies two bytes.

Syntax and interpretation

ConceptHow to apply it
RangesCheck that field boundaries match the protocol specification. Look for accidental gaps or overlap.
UnitsState whether the surrounding document uses bits or bytes. Do not silently switch between the two.
InterpretationByte order, signedness, and allowed field values need accompanying documentation; the box layout alone does not define them.

Common questions

Can I use it as a protocol validator?

No. It visualizes the supplied ranges. Test encoders and decoders separately against the actual protocol specification.