Packet diagrams are available in Mermaid v11.0.0+. Bit count syntax is available in v11.7.0+.
Who uses packet diagrams?
This diagram type is particularly useful for:- Network engineers designing or documenting network protocols
- Developers implementing network communication
- Educators teaching networking concepts
- Students learning about network packet structures
Basic packet diagram
This example shows a UDP packet structure:Syntax overview
There are two ways to define packet fields:Range syntax
Specify exact bit positions using start and end values:Bit count syntax (v11.7.0+)
Use+<count> to automatically calculate positions:
Adding titles
You can add a title to your packet diagram in two ways:Using frontmatter
Using inline title
Complete examples
TCP packet structure
UDP packet with bit count syntax
Mixing syntax styles
You can mix range syntax and bit count syntax in the same diagram:When using bit count syntax, the position starts from the end of the previous field. You can switch between syntax styles as needed.
Field details
Single-bit fields
For single-bit flags, use either syntax: Or:Multi-bit fields
For larger fields, specify the full range or bit count:Configuration
For detailed configuration options, see the packet diagram configuration reference.Configuration options
Configuration options
Packet diagrams support various configuration options:
- showBits: Toggle bit position display
- Styling options: Customize colors, fonts, and stroke widths
- Layout options: Adjust spacing and alignment