merIDK / Diagram types / Packet diagram
Mermaid packet diagram: example and syntax
Packet diagrams lay out the bit fields of a network packet or binary format. Engineers use them to document protocols such as TCP, UDP or their own file formats.
Open this example in the editor
Example code
---
title: "UDP header"
---
packet
0-15: "Source port"
16-31: "Destination port"
32-47: "Length"
48-63: "Checksum"
64-95: "Data (variable)"
Result
--- title: "UDP header" --- packet 0-15: "Source port" 16-31: "Destination port" 32-47: "Length" 48-63: "Checksum" 64-95: "Data (variable)"
Syntax quick reference
- Each field:
start-end: "Name", counted in bits. - Single-bit fields:
106: "URG". - By default each row is 32 bits wide.
How to use it
- Open the example in the editor, or paste your own Mermaid code.
- Edit the code on the left. The preview updates as you type, and errors point to the line.
- Export SVG or PNG, copy a Markdown block for GitHub or Notion, or copy a share link.