Mermaid reference: kinds of diagram
The full syntax, colors, exports and limits of Mermaid & PlantUML Diagrams for Confluence. It is written for people who already write Mermaid.
New to Mermaid? Start with the guide. Syntax not covered here is on mermaid.js.org.
This page uses Mermaid's word node (box) for a shape in a diagram. Every fact here is true of version 2.10.0. PlantUML, which 2.10.0 adds, has a reference of its own.
On this page
The first line that is not blank, a comment or front matter sets the kind. The app draws 32 kinds, with Mermaid 12.3.0. Each has an example under Examples and a Syntax reference panel of its own. Eight examples are buttons, and the other 24 are in the More… list beside them.
| First line | Kind | In Examples | Syntax reference panel |
|---|---|---|---|
| The eight buttons | |||
flowchart or graph | Flowchart | Flowchart | Flowchart |
sequenceDiagram | Sequence diagram | Sequence | Sequence diagram |
erDiagram | Entity relationship diagram | ERD | Entity relationship |
gantt | Gantt chart | Gantt | Gantt chart |
classDiagram | Class diagram | Class | Class diagram |
stateDiagram-v2 | State diagram | State | State diagram |
pie | Pie chart | Pie | Pie chart |
mindmap | Mind map | Mind map | Mind map |
| Under More… | |||
journey | User journey | User journey | User journey |
timeline | Timeline | Timeline | Timeline |
quadrantChart | Quadrant chart | Quadrant chart | Quadrant chart |
gitGraph | Git graph | Git graph | Git graph |
C4Context; also C4Container, C4Component, C4Dynamic, C4Deployment | C4 diagram | C4 | C4 diagram |
requirementDiagram | Requirement diagram | Requirement | Requirement diagram |
sankey | Sankey diagram | Sankey | Sankey diagram |
xychart | XY chart: bars and lines | XY chart | XY chart |
block | Block diagram | Block | Block diagram |
packet | Packet diagram | Packet | Packet diagram |
kanban | Kanban board | Kanban | Kanban board |
architecture-beta | Architecture diagram | Architecture | Architecture diagram |
radar-beta | Radar chart | Radar | Radar chart |
treemap-beta | Treemap | Treemap | Treemap |
treeView-beta | Tree view of files and folders | Tree view | Tree view |
ishikawa-beta | Fishbone (Ishikawa) diagram | Fishbone | Fishbone diagram |
venn-beta | Venn diagram | Venn | Venn diagram |
usecase-beta | Use case diagram | Use case | Use case diagram |
swimlane-beta | Swimlane diagram | Swimlanes | Swimlane diagram |
wardley-beta | Wardley map | Wardley map | Wardley map |
cynefin-beta | Cynefin diagram | Cynefin | Cynefin diagram |
railroad-ebnf-beta | Railroad (grammar) diagram | Railroad | Railroad diagram |
eventmodeling | Event model | Event model | Event model |
agentflow-beta | Agent flow | Agent flow | Agent flow |
The first line in the table is the one the kind's example starts with. Any first line the panel does not recognize shows the flowchart panel. ZenUML is not drawn: Mermaid publishes it as a separate package, which the app does not include. Mermaid's full syntax for every kind is on mermaid.js.org.
Flowchart
In the Syntax reference panel
| Write | Meaning |
|---|---|
| Shapes | |
A[Rectangle] | Standard box |
A(Rounded) | Rounded box |
A([Stadium]) | Pill shape |
A{Decision} | Diamond — a yes/no branch |
A((Circle)) | Circle |
A[(Database)] | Cylinder |
A[[Subroutine]] | Box with side bars |
| Arrows | |
A --> B | Solid arrow |
A --- B | Line, no arrowhead |
A -.-> B | Dotted arrow |
A ==> B | Thick arrow |
A -->|label| B | Arrow with a label |
| Direction | |
flowchart LR | Left to right |
flowchart TD | Top down |
| Color | |
style A fill:#ffd966 | Fill one node |
style A fill:#ffd966,stroke:#b45309,stroke-width:2px | Fill + border |
classDef warn fill:#fee2e2,stroke:#dc2626 | Define a reusable style |
class A,B warn | Apply that style to nodes |
The panel also has a Links group; see Links.
More
| Write | Meaning |
|---|---|
flowchart TB, RL, BT | Top to bottom (the same as TD), right to left, bottom to top |
subgraph id [Title] … end | A labeled group of nodes |
A["Cost (EUR)"] | A label with brackets or other symbols, in double quotes |
A["Line one<br>Line two"] | A line break in a label |
%% note | A comment, not drawn. It needs a line of its own: after other text on a line, it is a parse error. |
end is a reserved word, so a node cannot be called
end. Use End or done.
Subgraphs that set their own direction
A subgraph can hold a direction line of its own, such
as direction TB in a flowchart that runs left to
right. Mermaid 12 does not always follow it. Before version 2.9
the app drew with Mermaid 11.16, which did.
-
Standard layout. A subgraph loses its direction
when an arrow has one end inside it and the other outside. An
arrow from or to the subgraph itself, as in
One --> Two, costs it nothing. - ELK layout. An arrow whose two ends do not sit directly in the same subgraph costs every subgraph between either end and the subgraph that holds both its direction.
- A subgraph whose direction is the same as that of the diagram around it loses nothing.
When a flowchart draws and a subgraph is not drawn in its own
direction, the editor shows a note under the status line,
Subgraph direction not followed. It names the
subgraphs, gives the reason and says what to write for each arrow,
as in "Arrow A2 to B1: write
One for A2 and Two for
B1." It lists three arrows and counts the rest, which
appear as the first are changed. For a subgraph written without an
id, such as subgraph Team A, it gives the line that
sets one: subgraph TeamA [Team A].
- The diagram is valid and saves as it is. The editor never changes the source itself.
- In eleven test diagrams with the standard layout, writing the arrows as the note says gave back the drawing from before 2.9: ten exactly, and one with 0.08% of its pixels different.
- The note misses one rare case in the standard layout: an arrow to a subgraph that is itself crossed, three levels deep.
- The note does not show while the license is not active.
- State diagrams are not affected: a composite state's own direction is drawn as before.
Mermaid's page: Flowcharts. Recipe: Draw a process. Guide: A flowchart whose subgraphs lost their direction.
Sequence diagram
In the Syntax reference panel
| Write | Meaning |
|---|---|
| Basics | |
participant Bob | Declare a participant |
A->>B: Hello | Solid arrow with message |
A-->>B: Hi back | Dashed reply arrow |
A-)B: Async | Open arrowhead |
| Structure | |
Note over A,B: text | Note spanning participants |
loop Every minute | Start a loop block (end with end) |
alt Success | Conditional block (else / end) |
activate A | Show A as busy (deactivate A) |
More
| Write | Meaning |
|---|---|
autonumber | Number every message |
actor Customer | A participant drawn as a person |
participant Desk as Service desk | A short name with a longer label |
Note left of A: text, Note right of A: text | A note beside one participant |
opt … end | An optional block |
par … and … end | Blocks that happen at the same time |
A->>+B: Hi, B-->>-A: Done | Activate B with the first message, deactivate it with the reply |
Mermaid's page: Sequence diagrams. Recipe: Show who talks to whom.
Entity relationship diagram
In the Syntax reference panel
| Write | Meaning |
|---|---|
| Relationships | |
A ||--|| B : label | Exactly one to exactly one |
A ||--o{ B : label | One to zero-or-many |
A ||--|{ B : label | One to one-or-many |
A }o--o{ B : label | Many to many |
| Reading the symbols | |
|| | Exactly one |
o| | Zero or one |
}| | One or many |
}o | Zero or many |
| Attributes | |
CUSTOMER { string name }, one field per line | Fields go in braces |
string name PK | Mark a primary key |
More
| Write | Meaning |
|---|---|
A ||--o{ B : "appears on" | A relationship label with spaces, in double quotes |
A ||..o{ B : label | A dashed line: a non-identifying relationship |
int customer_id FK | Mark a foreign key; UK marks a unique key |
Mermaid's page: Entity relationship diagrams. Recipe: Document tables.
Mermaid Gantt chart syntax
A Gantt chart starts with gantt and a dateFormat, then one task per
line: its name, a colon, then optional tags (done, active,
crit, milestone) and an id, a start date or after
another task, and a length such as 3d. Examples to copy are in the
recipes.
In the Syntax reference panel
| Write | Meaning |
|---|---|
| Structure | |
title My Plan | Chart title |
dateFormat YYYY-MM-DD | How dates are written |
section Build | Group tasks under a heading |
| Tasks | |
Design :des1, 2026-08-01, 7d | id, start date, duration |
Dev :active, dev1, after des1, 14d | Starts when des1 ends |
Test :done, tst1, 2026-08-20, 5d | Completed task |
Launch :milestone, 2026-09-01, 0d | Milestone marker |
More
| Write | Meaning |
|---|---|
axisFormat %d %b | How the axis writes dates, here 05 Oct |
tickInterval 1week | One axis mark per week; also day, month and shorter units |
excludes weekends | Skip Saturdays and Sundays; also takes weekday names and dates, separated by commas |
weekend friday | With excludes weekends, skip Friday and Saturday instead; also weekend saturday |
includes 2026-12-27 | Keep a date that excludes would skip |
todayMarker off | Hide the line that marks today |
todayMarker stroke-width:3px,stroke:#1f9e7d | Style that line |
inclusiveEndDates | An end date counts as a day of the task |
done, active, crit, milestone | Tags before the id. They can be combined, as in crit, active |
after id, after id1 id2 | Start when the task ends; with several ids, when the last of them ends |
until id | End when that task starts |
A task's start is a date or after. Its end is a length,
a date, or until.
A length is a number and a unit: ms, s,
m, h, d, w,
M or y. Lowercase m is
minutes, and capital M is months.
A # or ; after a task's colon causes an
error. Write dates the way dateFormat says.
Mermaid's page also lists topAxis. In the Mermaid this
app includes, it causes an error, so leave it out.
Mermaid's page: Gantt diagrams. Recipe: Plan a project timeline.
Class diagram
In the Syntax reference panel
| Write | Meaning |
|---|---|
| Members | |
+name | Public |
-secret | Private |
#internal | Protected |
+total() float | Method with return type |
| Relationships | |
A <|-- B | B inherits from A |
A *-- B | Composition |
A o-- B | Aggregation |
A --> B : label | Association |
A "1" --> "*" B | With multiplicity |
More
| Write | Meaning |
|---|---|
class Order { … } | A class and its members, one per line |
A ..> B | Dependency |
A ..|> B | Realisation |
<<interface>> Shape | An annotation on a class |
Mermaid's page: Class diagrams. There is no recipe for class diagrams; start from the Class example.
State diagram
In the Syntax reference panel
| Write | Meaning |
|---|---|
| Basics | |
[*] --> Draft | Start state |
Draft --> [*] | End state |
A --> B : trigger | Transition with label |
| Grouping | |
state "Long name" as s1 | Alias a state |
state Fork <<fork>> | Fork / join node |
note right of A : text | Attach a note |
More
| Write | Meaning |
|---|---|
state Review { … } | A state with states inside it |
state Check <<choice>> | A choice between paths |
direction LR | Draw from left to right |
Mermaid's page: State diagrams. Recipe: Show how statuses change.
Pie chart
In the Syntax reference panel
| Write | Meaning |
|---|---|
| Basics | |
pie title My Chart | Chart heading |
"Label" : 45 | One slice and its value |
showData | Show numbers on the chart |
showData goes on the first line, after
pie. It adds each value to the key, in square brackets.
A title can also go on a line of its own, as
title Tickets by channel.
Mermaid's page: Pie charts. Recipe: Show shares of a whole.
Mind map
In the Syntax reference panel
| Write | Meaning |
|---|---|
| Basics | |
root((Centre)) | Central node |
Child | Indent two spaces per level |
id[Square] | Square node |
id(Rounded) | Rounded node |
More
| Write | Meaning |
|---|---|
id((Circle)) | Circle |
id))Bang(( | Bang |
id)Cloud( | Cloud |
id{{Hexagon}} | Hexagon |
A node's level comes from its indentation, compared with the lines above it.
The other 24 kinds
Each kind under More… has an example and a Syntax reference panel in the editor, and is a Diagram type in Draft with AI. This page does not repeat those panels; Kinds of diagram lists the 24. Two of them have something worth knowing here.
XY chart: the legend
An XY chart lists the names of its lines and bars in a legend. A
line or bar has a name when it is written with one, as in
line "Target" [35, 45, 50]. Before version 2.9, those
names were not shown. To leave the legend out of one chart, begin
the diagram with:
---
config:
xyChart:
showLegend: false
---Timeline: sections
In a timeline with section headings, periods written
above the first heading are not drawn. Put every period under a
heading, or use no headings.
Recipes: Map a customer journey and Show a timeline.