Example
packet-beta
title HTTP Request Packet
0-7: "Version (4)"
8-15: "IHL (5)"
16-31: "Total Length"
32-63: "Identification | Flags | Fragment Offset"
64-71: "TTL"
72-79: "Protocol (TCP=6)"
80-95: "Header Checksum"
96-127: "Source IP Address"
128-159: "Destination IP Address"
160-191: "Options (if IHL > 5)" Syntax
Fields
packet-beta
title TCP header
0-15: "Source port"
16-31: "Destination port"
32-63: "Sequence number"
64-95: "Acknowledgment number"
96-99: "Data offset"
100-105: "Reserved"
106-111: "Flags"
112-127: "Window" Ranges are inclusive and must be contiguous from 0. A single bit is written as 96: "Flag". The -beta suffix is still required in Mermaid 11.
Common mistakes
These are the parse errors that come up most, including in code written by ChatGPT and Claude. Paste any failing diagram into the editor and it marks the offending line.
-
A gap or overlap between ranges (
0-7, then9-15).Fix: Every bit must be covered exactly once in ascending order. Add a
"Reserved"field to fill gaps. -
Field label without quotes.
Fix: Labels are quoted strings:
0-7: "Version".
FAQ
Can a field span more than one 32-bit row?
Yes. A range such as 96-159 renders as a two-row block, which is how 64-bit fields are drawn.
Can I change the row width from 32 bits?
Not in the diagram text as of Mermaid 11. The packet diagram is fixed at 32 bits per row, matching RFC convention.