PlantUML vs Mermaid syntax side-by-side: 7 common diagrams, line by line
After the macro comparison, this article is the cheat sheet for “when you actually want to draw a diagram”. Each diagram type gives you: minimal example → key differences → common pitfalls — just copy-paste to run.
Overview: which diagram types are “equally strong”
| Diagram type | PlantUML | Mermaid | Who is stronger |
|---|---|---|---|
| Sequence | ✅ | ✅ | PlantUML (fragment / step / ref) |
| Class | ✅ | ✅ | PlantUML (complete association semantics) |
| Flowchart | ✅ | ✅ | Mermaid (more intuitive syntax) |
| ER | ✅ | ✅ | Tie |
| State | ✅ | ✅ | PlantUML (nesting / concurrency) |
| Gantt | ✅ | ✅ | Mermaid (task dependencies more intuitive) |
| C4 architecture | ✅ built-in stdlib | ❌ needs plugin | PlantUML |
Going one by one.
1. Sequence diagram
Minimal example: Alice/Bob auth flow
PlantUML:
1 | @startuml |
Mermaid:
1 | sequenceDiagram |
Key differences:
| Axis | PlantUML | Mermaid |
|---|---|---|
| Start markers | @startuml / @enduml |
sequenceDiagram keyword |
| Solid arrow | -> |
->> |
| Dashed arrow | --> |
-->> |
| Self-call | A -> A: ... |
A->>A: ... |
| Async message | ->> ⇢ |
->> no distinction; use Note right of A: async |
| Groups (alt/else/opt/loop) | Native alt/else/opt/loop/end |
Native alt/else/opt/loop/end |
| Notes | note left of User: ... |
Note left of User: ... (capitalized) |
| Participant decl | actor User / participant "User Service" as US |
actor User / participant US as User Service |
| Numbering | Auto | Auto |
| Activation lifeline | activate A / deactivate A |
activate A / deactivate A |
| Cross-diagram ref | ref over A: ... |
v11+: ref over A: ... |
Pitfalls:
- Mermaid’s
actormust be in the scope right aftersequenceDiagram, can’t move mid-diagram - PlantUML
note left/right/overkeyword must be lowercase (note) - Both require
elseorendinsidealtblocks (Mermaid strict, PlantUML tolerant)
2. Class diagram
Minimal example: User / Order
PlantUML:
1 | @startuml |
Mermaid:
1 | classDiagram |
Key differences:
| Axis | PlantUML | Mermaid |
|---|---|---|
| Visibility | +/-/#/~ |
+/-/#/~ (same) |
| Static / abstract | {static} / {abstract} |
<<static>> / <<abstract>> stereotypes |
| Association arrows | --> (assoc) --|> (inherit) ..|> (impl) ..> (dep) |
Same |
| Multiplicity | "1" --> "*" |
Same |
| Notes | note left of User: ... |
note for User "..." (v11+) |
| Package / namespace | package com.example { ... } |
namespace com.example { ... } |
| Generics | class List~T~ |
class List~T~ (same) |
| Interface | interface Payable |
<<interface>> stereotype |
| Enum | enum Status { ACTIVE INACTIVE } |
Not native (use class to simulate) |
Pitfalls:
- Mermaid implementation uses
..|>(not..>), easy to mistype - Mermaid nested class support is weak; complex hierarchies → PlantUML
- PlantUML
+login(pwd: String): Token— after the colon you cannot write a method body with spaces
3. Flowchart
Minimal example: user login decision tree
PlantUML:
1 | @startuml |
Mermaid:
1 | flowchart TD |
Key differences:
| Axis | PlantUML | Mermaid |
|---|---|---|
| Direction | top to bottom direction default |
flowchart TD / LR explicit |
| Node shapes | rectangle / diamond / circle keywords |
[ ] { } (( )) ([ ]) symbols |
| Labels | node1 --> "label text" |
node1 -->|label| node2 |
| Subgraph | rectangle cluster { ... } |
subgraph ... end |
| Styling | node1 #lightblue |
classDef + class binding |
| Start/end | (*) |
([ ]) stadium |
| Comments | Single line limited | %% line comment |
Pitfalls:
- Mermaid node labels with special chars (
/,[],()) need quoting - PlantUML flowchart is weaker than sequence/class; complex flows → use Mermaid or upgrade to PlantUML activity
- Mermaid v10+ supports same-named
subgraphreuse
4. ER diagram
Minimal example: User / Order / Product
PlantUML:
1 | @startuml |
Mermaid:
1 | erDiagram |
Key differences:
| Axis | PlantUML | Mermaid |
|---|---|---|
| FK annotation | <<FK>> inline |
Long user_id FK (after field name) |
| PK | <<PK>> |
PK suffix |
| Cardinality | ||--o{ }o--|| |
Same |
| Relationship name | User --> Order: places |
USER ||--o{ ORDER : places |
| Weak entity | entity Weak + relation ..|> |
❌ not supported |
| Inheritance | Parent <|-- Child |
❌ not supported |
Pitfalls:
- Mermaid PK/FK keywords must immediately follow the field name (space-separated)
- PlantUML ER is essentially an entity class diagram; can add methods; Mermaid ER only holds fields
- Complex schema (10+ tables) → PlantUML; simple 3-5 tables → Mermaid is faster to write
5. State machine
Minimal example: order state machine
PlantUML:
1 | @startuml |
Mermaid:
1 | stateDiagram-v2 |
Key differences:
| Axis | PlantUML | Mermaid |
|---|---|---|
| Start marker | [*] |
[*] (same) |
| Nesting | state Outer { state Inner { ... } } |
state Outer { ... } |
| Concurrency | state A { -- || ==} |
Not supported |
| Choice | state c1 <<choice>> |
state c1 <<choice>> (same) |
| History state | state X <<history>> |
❌ not supported |
| Notes | note right of State: ... |
note right of State : ... |
| Entry/exit actions | State : entry / action |
Not supported |
Pitfalls:
- Mermaid must use
stateDiagram-v2(v1 deprecated) - PlantUML deep nesting gets messy; wrap with
package - Mermaid nested state indentation must be strict (4 or 2 spaces consistently, no mixing)
6. Gantt
Minimal example: two-week sprint plan
PlantUML:
1 | @startuml |
Mermaid:
1 | gantt |
Key differences:
| Axis | PlantUML | Mermaid |
|---|---|---|
| Task dependency | starts at [task]'s end |
after a1 (using alias) |
| Milestone | today is milestone |
:milestone, m1, 2026-08-10, 0d |
| Progress | [task] lasts 5 days and is 60% completed |
:a3, after a2, 5d + done status |
| Status | done active crit |
done active crit |
| Grouping | Implicit (by order) | section explicit |
| Date format | dateformat YYYY-MM-DD |
dateFormat YYYY-MM-DD |
| Workdays | monday are closed |
Not supported |
Pitfalls:
- PlantUML alias must be
[a] as [b]declared upfront to reference later - Mermaid milestone uses
0d - PlantUML lacks
sectionexplicit grouping; long Gantts get messy
7. C4 architecture
Minimal example: System Context
PlantUML (using C4-PlantUML stdlib):
1 | @startuml |
Mermaid (v11+ experimental):
1 | %%{init: {"theme": "default"}}%% |
Key differences:
| Axis | PlantUML | Mermaid |
|---|---|---|
| C4 support | Official stdlib (25+ built-in diagrams) | v11+ experimental, needs %%{init}%% |
| Container / Component / Dynamic | All present | Also present (v11+) |
| Themes | LAYOUT_WITH_LEGEND() dozens |
Default 1 |
| Deployment | Deployment_Node |
C4Deployment |
| Risk | None (mature) | v11+ API changes, docs lacking |
Conclusion: For C4, PlantUML wins handily. Mermaid only supports C4 from v11+, syntax is unstable, docs lag.
Quick reference: 5 most common pitfalls
- Mermaid notes:
note left of A: ...(capitalized) - PlantUML notes:
note left of A: ...(lowercase) - Arrow direction: Mermaid solid
->>dashed-->>(double>); PlantUML solid->dashed--> - Class realize: Both use
..|>(not..>) - State diagram start: Mermaid must use
stateDiagram-v2, notstateDiagram
Cross-tool migration tips
- PlantUML → Mermaid: Class and sequence migrate most cleanly; ER and state lose some attributes
- Mermaid → PlantUML: PlantUML syntax is more permissive; almost always works; watch out for
flowchart→ PlantUML activity losing some node shapes - Auto-convert tools:
mermaid-to-plantuml(Node CLI) andplantuml-to-mermaid(Python, bigger loss)
How to decide: which to draw with?
Back to the decision:
- Simple flowcharts / README / doc embedding → Mermaid (copy-paste ready)
- Strict UML / complex class / C4 → PlantUML
- GitHub README → Mermaid (native
```mermaid) - CI batch validation → PlantUML (CLI is rigorous)
- Cross-language (Chinese/Japanese/emoji) → Mermaid first (fewer font issues)
Further reading
- Macro comparison: PlantUML vs Mermaid: two ‘text-to-diagram’ philosophies
- Pros/cons panorama: PlantUML vs Mermaid pros/cons + decision tree
- Cross-tool migration: PlantUML cross-tool migration: D2, Mermaid, Draw.io
- Title: PlantUML vs Mermaid syntax side-by-side: 7 common diagrams, line by line
- Author: puml.online
- Created at : 2026-08-04 09:30:00
- Updated at : 2026-08-14 21:34:29
- Link: https://puml.online/blog/plantuml-mermaid-syntax-en/
- License: This work is licensed under CC BY-NC-SA 4.0.