UDP header
Four 16-bit fields. The range is inclusive: 0-15 is 16 bits, starting at bit 0.
packet-beta
0-15: "Source Port"
16-31: "Destination Port"
32-47: "Length"
48-63: "Checksum"A packet diagram is a bit layout. Each line is a field, from a start bit to an end bit, with a label.
Copy an example, or open it in the live editor with this diagram already loaded.
Four 16-bit fields. The range is inclusive: 0-15 is 16 bits, starting at bit 0.
packet-beta
0-15: "Source Port"
16-31: "Destination Port"
32-47: "Length"
48-63: "Checksum"Single-bit fields use one number. Wider fields use a range. This is the flag byte area of a TCP header, not the whole header.
packet-beta
0-3: "Data Offset"
4-9: "Reserved"
10: "URG"
11: "ACK"
12: "PSH"
13: "RST"
14: "SYN"
15: "FIN"The same syntax documents an internal binary format. Pick bit numbers that match the struct you actually write.
packet-beta
0-7: "Version"
8-15: "Type"
16-31: "Length"
32-63: "Request id"A Mermaid packet diagram documents a binary header the way an RFC does. The diagram starts with packet-beta. A field is either start-end: "Label" for a range or bit: "Label" for a single flag. Bits are numbered from 0, and Mermaid wraps the drawing into rows. Use it for a protocol header or a binary file format. It is not a network topology; boxes and arrows between servers belong on an architecture or block diagram.
Use a packet diagram when the subject is bits and field widths. Use an architecture diagram for hosts and networks. Use a flowchart for the protocol's behavior rather than its header.
Edit this packet diagram in the live editor, read the Mermaid cheat sheet, or compare it with Block Diagram, Flowchart and Architecture Diagram.
| Element | Syntax | Description |
|---|---|---|
| Single bit | N: "Label" | One-bit field at position N |
| Bit range | N-M: "Label" | Multi-bit field from N to M |
| Field label | "Field Name" | Name of the packet field |
Counting 0-15 as 15 bits.
The ends are inclusive. 0 through 15 is 16 bits. The next field starts at 16.
Overlapping ranges, such as 0-15 and 15-31.
The next field starts at the bit after the previous end. 0-15 is followed by 16-31.
Using a packet diagram to draw routers and servers.
Packet diagrams are bit fields. Draw the network with an architecture or block diagram.
Header diagrams are documentation. SVG stays readable when the page is zoomed onto a flag. Free PNG exports include a watermark.
High-resolution images for documents and presentations.
Scalable vectors for web and further editing.
Print-ready format for professional documentation.
Got Mermaid code from ChatGPT? Paste it here to render and export instantly.
All 21 diagram types in one PDF reference.
Open the editor with this example pre-loaded and start customizing.
Design system architectures, hardware layouts, and component diagrams with flexible block arrangements.
Design process flows, decision trees, and workflows with our intuitive flowchart editor.
Visualize cloud infrastructure, service architectures, and system design with architecture diagrams.