Network topology diagrams with PlantUML and Mermaid
简介 / Introduction
A network topology diagram is one of the most common artifacts in operations and architecture docs: it shows how servers and links are arranged across the public internet, a DMZ, and the core network. This post draws the exact same “internet → DMZ → core” topology twice — first with PlantUML’s nwdiag engine, then with Mermaid’s flowchart plus subgraph — and compares what each engine can express.
PlantUML 版
PlantUML ships with Takeshi Komiya’s nwdiag engine, enabled via @startnwdiag. A network is declared as a network block, and each block can carry a subnet via address. Nodes are declared as id [address = "..."]. Links between networks use --, while nodes inside the same network automatically attach to that network’s bus bar.
1 | @startnwdiag |
A few nwdiag constraints are worth knowing up front: subnet and group names must not be quoted, and a link cannot carry a [label = "..."] attribute (it fails with a Syntax Error). The only accepted arrow form is --.
Mermaid 版
Mermaid has no dedicated topology engine, but flowchart with subgraph reaches the same visual result. A subgraph plays the role of a PlantUML network / group block, IP addresses go inside the node label separated by <br/>, and edge labels use the -->|"text"| form to carry protocol and port.
1 | flowchart TB |
Mermaid subgraph titles can include the subnet directly, and -->|"..."| edge labels have none of the restrictions that nwdiag places on links.
对比 / Side-by-side
| Feature | PlantUML nwdiag |
Mermaid flowchart |
|---|---|---|
| Engine entry | @startnwdiag / @enduml |
flowchart TB |
| Network partition | network dmz { ... } |
subgraph DMZ["..."] |
| Node address | proxy [address = "10.0.0.10"] |
inside the label: proxy["...<br/>10.0.0.10"] |
| Link | proxy -- app; (no label) |
`proxy –> |
| Grouping and color | group / color = "palegreen" |
subgraph + style directive |
| Node shapes | shape = cloud / shape = database |
Mermaid node shapes or sprite icons |
| Layout | nwdiag auto-places bus bars | Mermaid dagre auto-layout |
小结 / Wrap-up
Both engines can produce a readable network topology, but they optimize for different things. PlantUML’s nwdiag is network-semantics-first: subnets, bus bars, and addresses are built in, which maps cleanly onto a real segmented network. Mermaid’s flowchart is diagram-expression-first: edge labels and node shapes are far more flexible, which makes it a better fit for documentation that mixes topology with other concepts. Keep in mind that nwdiag is stricter than it looks — no quoted subnet names, no labeled links — and when you hit those limits, switching to Mermaid is usually the faster path.
- Title: Network topology diagrams with PlantUML and Mermaid
- Author: puml.online
- Created at : 2026-10-22 01:05:00
- Updated at : 2026-10-22 01:06:32
- Link: https://puml.online/blog/network-diagram-topology-en/
- License: This work is licensed under CC BY-NC-SA 4.0.