PlantUML vs Mermaid vs Graphviz DOT vs D2 — a complete DSL comparison
There are now more “text-first diagram tools” than 5 years ago — PlantUML / Mermaid / Graphviz DOT / D2. Which to pick? This post compares them against real scenarios.
One-line summary
| Tool | Main field | One-line pitch |
|---|---|---|
| PlantUML | Engineering/UML | JVM DSL, strongest UML expressiveness |
| Mermaid | Docs / blogs | Browser-native, zero friction |
| Graphviz | Academic / data | Old guard, founder of graph layout algorithms |
| D2 | Modern architecture | From Terrastruct, next-gen DSL |
PlantUML
Strengths
- Full UML family: sequence, state, class, activity, usecase, component, deployment, object — almost every UML diagram has dedicated syntax
- Functional style:
!define / !function / !include / !pragma, programmable - Theme ecosystem:
!themeplus 20+ ready-made themes (cyborg / sketchy / crt-green, etc) - Multi-runtime: Java CLI / docker server / WASM / online service
Pain points
- JVM dependency: CLI render requires Java; server docker image is 200MB+
- Slows at scale: 100+ nodes + Graphviz dot stutter (→ use ELK)
- Styling limits: limited built-in skins; custom CSS not possible
- Learning curve:
!pragma/!define/<<stereotype>>are opaque to newcomers
Mermaid
Strengths
- Browser-native: pure JS; GitHub / GitLab / Notion / Obsidian all support it inline
- Zero install: drop a
mermaidmarkdown block and it renders - Common diagrams: flow / sequence / class / gantt / pie / state / ER all there
- Lowest learning curve: 5 minutes to first diagram
Pain points
- Limited styling:
skin/themeare independent CSS-like key/values; precise control over node colour, font, spacing is awkward - Slow at scale too: Canvas rendering, sluggish past ~50 nodes
- UML coverage thin: class diagram supports fields + methods only; sequence and state machine are passable
- No server: only browser, or the official CLI (less functional than the browser)
- PDF fidelity is poor (HTML → print → meh)
Graphviz DOT
Strengths
- Grandfather of graph tools: born 1991, the source of graph layout algorithms (dot / neato / fdp / sfdp / circo)
- Most algorithms: 5 layouts, each suited to a different shape
- Pure text: zero dependencies; one of the easiest visualisations for LLMs to generate correctly
- Composable with shell tools:
csv2gprof | dot -Tsvg
Pain points
- Not UML: only draws graphs (nodes + edges); sequence / state machines must be hand-built
- Old syntax:
digraph G { a -> b }is hard to debug in large graphs - Styling is fiddly: every colour, shape, edge style needs an
attr - CJK fonts: need explicit fontname=…; slow overall without tuning
D2
Strengths
- Modern DSL: Go / TypeScript influence; consistent syntax, IDE-friendly autocomplete
- Layout algorithms: ELK / dagre / d2’s own (3 options)
- Styling as core:
style.fill: .../shape: ..., Figma-grade control - Terraform / Postgres integration: from
d2 -hread external data sources directly (e.g.arch.pngauto-rendered from a terraform state) - Browser WASM-friendly: layout can run in browser via dagre-wasm
Pain points
- Ecosystem is young: only v0.6+ in 2024; few enterprise adoption stories
- UML coverage thin: only
class-diagram; sequence / state / deployment are missing - Community docs are immature: bug-reporting leads to GitHub issues
- JS render is heavy: browser D2 is 1MB+; bad on mobile
- Chinese docs are scarce: only “intro” level exists in Chinese
Decision matrix: which when
| Your scenario | Recommended |
|---|---|
| Diagrams in GitHub README | Mermaid |
| Enterprise docs / internal wiki | PlantUML (lowest ops cost) |
| Microservice architecture (200+ nodes) | D2 or PlantUML + ELK |
| Full UML (sequence / state / activity) | PlantUML |
| Academic paper / data-flow diagrams | Graphviz DOT |
| Real-time monitoring dashboards (auto-refresh) | Mermaid / D2 |
| Offline / no deployment assumptions | PlantUML (with JAR) or native Graphviz |
| With LangChain / LLM-generated flow charts | Mermaid / D2 |
| Embed in Hexo / VuePress / Docusaurus | PlantUML or Mermaid (both) |
| Reverse-engineering (Java class → diagram) | PlantUML (built-in IDEA integration) |
Interop
PlantUML ↔ Mermaid
No official tool, just community packages:
plantuml2mermaid/mermaid2plantuml— npm packages, only simple diagrams- Manual translation: Mermaid sequence-diagram code is short, edit by hand
1 | sequenceDiagram |
1 | @startuml |
PlantUML ↔ Graphviz DOT
Open-source plantuml2dot by Yegor Bugayenko.
PlantUML ↔ D2
D2 official supports d2 --plantuml=... flag, but only one direction. PlantUML → D2 has no complete converter.
Graphviz DOT ↔ Mermaid
viz.js / graphviz-cli chain — only handles simple graphs.
Benchmark: a 30-node microservice diagram
| Tool | Cold render | Warm render | SVG size |
|---|---|---|---|
| PlantUML + dot | 1.2s | 200ms | 28KB |
| PlantUML + ELK | 2.5s | 500ms | 32KB |
| Mermaid | 600ms | 100ms | 18KB |
| Graphviz | 400ms | 50ms | 22KB |
| D2 + ELK | 800ms | 300ms | 16KB |
Conclusions:
- Mermaid is heaviest on cold start (100KB+ JS).
- Graphviz CLI is fastest (native C) but ugly output.
- PlantUML + ELK has the cleanest visual hierarchy.
- D2 is slightly slower but produces the most modern output.
My selection heuristics
“I” pick:
- Code-repo diagrams → PlantUML (stable API, full UML, JVM-friendly)
- GitHub README → Mermaid (zero config)
- Architecture whiteboarding → Graphviz dot (sketch on paper, write straight to dot, see diagram)
- Modern product docs → D2 (young ecosystem, but strong styling)
- Enterprise wiki (Feishu / Confluence) → Mermaid, with a path to PlantUML upgrade
Recap
There is no “best diagram DSL”. Only “DSL suited to the scenario”.
- PlantUML: engineering / UML / JVM integration → main weapon
- Mermaid: blogs / docs / lightweight diagrams → main weapon
- Graphviz: academic / automation / graph algorithms → auxiliary
- D2: modern styling / Terraform integration → fallback
Next
- PlantUML vs Mermaid vs Draw.io: which to pick for what
- Embedding PlantUML in Hexo (server-side / client-side) (actual slug:
plantuml-render-from-hexo)
- Title: PlantUML vs Mermaid vs Graphviz DOT vs D2 — a complete DSL comparison
- Author: puml.online
- Created at : 2026-07-30 10:21:00
- Updated at : 2026-08-14 21:34:29
- Link: https://puml.online/blog/plantuml-vs-mermaid-graphviz-d2-en/
- License: This work is licensed under CC BY-NC-SA 4.0.