Mermaid Diagramming in Obsidian
Obsidian has built-in Mermaid support. Use fenced code blocks with mermaid language identifier.
For common syntax (styling, comments, themes), see reference.md.
⚠️ Obsidian-Specific Constraints
Rendering Differences: Obsidian's Mermaid version may lag behind mermaid.js releases. Some cutting-edge features may not work.
Theme Interaction: Diagram colors adapt to Obsidian theme. Use explicit styles for consistent appearance across themes.
Performance: Very large diagrams (50+ nodes) may slow down rendering. Split into multiple diagrams if needed.
Export: PDF export converts diagrams to images. For external sharing, capture as PNG/SVG.
No JavaScript: Click events and JavaScript callbacks are disabled for security.
Diagram Selection Guide
| Use Case |
Diagram Type |
Keyword |
| Process flow, decision trees |
Flowchart |
flowchart |
| API calls, message passing |
Sequence |
sequenceDiagram |
| OOP design, relationships |
Class |
classDiagram |
| Project timeline, scheduling |
Gantt |
gantt |
| State machine, lifecycle |
State |
stateDiagram-v2 |
| Git branching strategy |
Gitgraph |
gitGraph |
| Brainstorming, hierarchies |
Mindmap |
mindmap |
| Proportions, percentages |
Pie Chart |
pie |
| Database schema, entities |
ER Diagram |
erDiagram |
| User experience steps, satisfaction |
User Journey |
journey |
| Historical events, milestones |
Timeline |
timeline |
| Priority matrix, 2D positioning |
Quadrant Chart |
quadrantChart |
| Flow visualization, proportional bands |
Sankey Diagram |
sankey-beta |
| Numerical data visualization |
XY Chart |
xychart-beta |
| Precise element positioning, layouts |
Block Diagram |
block-beta |
| Cloud services, service relationships |
Architecture |
architecture-beta |
Quick Start Examples
Flowchart
flowchart TD
A[Start] --> B{Decision}
B -->|Yes| C[Action 1]
B -->|No| D[Action 2]
C --> E[End]
D --> E
Key syntax:
- Direction:
TD (top-down), LR (left-right), BT, RL
- Shapes:
[rect], (rounded), {diamond}, [(cylinder)], ((circle))
- Arrows:
-->, -.-> (dotted), ==> (thick)
- Labels:
-->|text| or -- text -->
For details: flowchart.md
Sequence Diagram
sequenceDiagram
participant C as Client
participant S as Server
participant D as Database
C->>S: HTTP Request
activate S
S->>D: Query
D-->>S: Result
S-->>C: Response
deactivate S
Key syntax:
- Arrows:
->> (sync), -->> (response), -) (async)
- Activation:
activate/deactivate or +/- suffix
- Control:
loop, alt/else, opt, par/and, critical
- Notes:
Note right of A: text, Note over A,B: text
For details: sequence.md
Class Diagram
classDiagram
class Animal {
+String name
+int age
+makeSound() void
}
class Dog {
+fetch() void
}
Animal <|-- Dog : extends
Key syntax:
- Visibility:
+ public, - private, # protected, ~ package
- Relations:
<|-- inheritance, *-- composition, o-- aggregation, --> association
- Methods:
+method(args) returnType
For details: class-diagram.md
Gantt Chart
gantt
title Project Timeline
dateFormat YYYY-MM-DD
section Planning
Requirements :a1, 2024-01-01, 7d
Design :a2, after a1, 5d
section Development
Implementation :2024-01-15, 14d
Testing :7d
Key syntax:
dateFormat: Date format (YYYY-MM-DD, etc.)
- Tasks:
name :id, start, duration or name :after id, duration
- Modifiers:
done, active, crit, milestone
For details: gantt.md
State Diagram
stateDiagram-v2
[*] --> Idle
Idle --> Processing : start
Processing --> Success : complete
Processing --> Error : fail
Success --> [*]
Error --> Idle : retry
Key syntax:
- Start/End:
[*]
- Transition:
State1 --> State2 : event
- Composite:
state Name { ... }
- Fork/Join:
state fork_name <<fork>>, <<join>>
For details: state.md
Gitgraph
gitGraph
commit id: "init"
branch develop
checkout develop
commit id: "feat-1"
commit id: "feat-2"
checkout main
merge develop id: "v1.0" tag: "release"
Key syntax:
commit: Add commit, optional id:, tag:, type:
branch name: Create branch
checkout name: Switch branch
merge name: Merge branch
For details: gitgraph.md
Mindmap
mindmap
root((Project))
Frontend
React
TypeScript
Backend
Node.js
PostgreSQL
DevOps
Docker
CI/CD
Key syntax:
- Indentation defines hierarchy
- Shapes:
root((circle)), (rounded), [square], ))cloud((
- Use 4-space or tab indentation
For details: mindmap.md
Pie Chart
pie showData
title Browser Market Share
"Chrome" : 65
"Safari" : 19
"Firefox" : 8
"Edge" : 5
"Other" : 3
Key syntax:
title: Optional chart title
showData: Display values on segments
- Format:
"Label" : value
For details: pie.md
ER Diagram
erDiagram
CUSTOMER ||--o{ ORDER : places
ORDER ||--|{ LINE-ITEM : contains
CUSTOMER {
int id PK
string email UK
string name
}
Key syntax:
- Entities:
ENTITY_NAME
- Attributes:
type name [PK/FK/UK]
- Cardinality:
||--o{ (one to many), ||--|| (one to one)
- Relationship:
ENTITY1 REL ENTITY2 : label
For details: er-diagram.md
User Journey
journey
title Customer Support
section Contact
Submit ticket: 2: Customer
Receive notice: 4: Agent
section Resolution
Troubleshoot issue: 3: Agent
Confirm solution: 5: Customer
Key syntax:
- Sections:
section name
- Tasks:
Task name: score: actor
- Score: 1-5 (1 = unsatisfied, 5 = satisfied)
- Actors: User roles involved
For details: journey.md
Timeline
timeline
title Product Roadmap
section 2023
Q1 2023 : MVP launch
Q4 2023 : v1.0 release
section 2024
Q2 2024 : Major features
Q4 2024 : v2.0
Key syntax:
- Time periods:
period : event
- Sections: Group related periods
- Multiple events:
period : event1 : event2
- Flexible format: Years, months, quarters, or custom text
For details: timeline.md
Quadrant Chart
quadrantChart
title Feature Prioritization
x-axis Effort --> Value
y-axis Complexity --> Impact
Dark Mode: [0.4, 0.7]
Search: [0.6, 0.8]
Export PDF: [0.7, 0.6]
Fix UI Bug: [0.2, 0.3]
Key syntax:
- Axes:
x-axis label --> label and y-axis label --> label
- Points:
Name: [x, y] (coordinates 0.0-1.0)
- Quadrants: Auto-divided at 0.5 on both axes
For details: quadrant-chart.md
Sankey Diagram
sankey-beta
A,B,10
A,C,15
B,D,8
C,D,22
Key syntax:
- CSV format:
source, target, value
- Three columns required
- Values are numeric (flow magnitude)
- Nodes auto-created from sources/targets
For details: sankey.md
XY Chart
xychart-beta
title "Sales Data"
x-axis [Jan, Feb, Mar, Apr, May]
y-axis "Revenue" 0 --> 100
line [30, 45, 55, 70, 85]
Key syntax:
- Chart type:
xychart-beta or xychart-beta horizontal
- X-axis:
[categories] or min --> max
- Y-axis:
"label" min --> max
- Series:
line [values] or bar [values]
For details: xychart.md
Block Diagram
block-beta
columns 2
A["Frontend"]:1
B["Backend"]:1
C["Database"]:2
style A fill:#e3f2fd,stroke:#1565c0,color:#0d47a1
style B fill:#f3e5f5,stroke:#7b1fa2,color:#4a148c
style C fill:#e8f5e9,stroke:#2e7d32,color:#1b5e20
Key syntax:
- Blocks:
ID["Label"]:SPAN - Each block on new line
- Columns:
columns N - Define layout width
- Styling:
style ID fill:#hex,stroke:#hex,color:#hex
- Spans:
:N suffix - How many columns block occupies
For details: block.md
Architecture Diagram
architecture-beta
group Cloud(cloud)[Cloud Infrastructure]
service web(server)[Web Server] in Cloud
service api(server)[API Server] in Cloud
service db(database)[Database]
web:R --> L:api
api:R --> L:db
Key syntax:
- Groups:
group {id}({icon})[{label}] - Organize services
- Services:
service {id}({icon})[{label}] (in {parent})? - Available icons: server, database, cloud, disk, internet
- Nesting:
in {parent_id} - Place service/group inside parent group
- Connections:
{id1}:{pos} {arrow} {pos}:{id2} - Position: L(eft), R(ight), T(op), B(ottom)
- Arrows:
--> (right), <-- (left), -- (both)
For details: architecture.md
Common Patterns
Adding Styles
flowchart LR
A[Normal] --> B[Styled]
style B fill:#f96,stroke:#333,stroke-width:2px
Using Classes
flowchart LR
A:::highlight --> B --> C:::highlight
classDef highlight fill:#ff0,stroke:#f00,stroke-width:2px
Comments
flowchart TD
%% This is a comment
A --> B
Reference
For complete documentation on common features:
- reference.md - Styling, themes, comments, directives
For diagram-specific guides:
- flowchart.md - Node shapes, links, subgraphs
- sequence.md - Messages, activation, control flow
- class-diagram.md - Classes, relationships
- gantt.md - Tasks, dependencies, milestones
- state.md - States, transitions, composite states
- gitgraph.md - Commits, branches, merges
- mindmap.md - Hierarchies, node shapes
- pie.md - Proportional data
- er-diagram.md - Entities, attributes, relationships (Session 1)
- journey.md - User journeys, satisfaction scores (Session 1)
- timeline.md - Events, milestones, time periods (Session 1)
- quadrant-chart.md - Priority matrix, 2D positioning (Session 2)
- sankey.md - Flow visualization, proportional bands (Session 2)
- xychart.md - Numerical data visualization (Session 2)
- block.md - Element positioning, multi-column layouts (Session 3)
- architecture.md - Cloud services, service relationships (Session 3)
1---
2name: mermaid-diagramming
3description: Create Mermaid diagrams in Obsidian including flowcharts, sequence diagrams, class diagrams, and more. Use when visualizing processes, system architectures, workflows, or any structured relationships in Obsidian notes.
4context: fork
5user-invocable: false
6---
7
8# Mermaid Diagramming in Obsidian
9
10Obsidian has built-in Mermaid support. Use fenced code blocks with `mermaid` language identifier.
11
12For common syntax (styling, comments, themes), see [reference.md](reference.md).
13
14## ⚠️ Obsidian-Specific Constraints
15
16**Rendering Differences**: Obsidian's Mermaid version may lag behind mermaid.js releases. Some cutting-edge features may not work.
17
18**Theme Interaction**: Diagram colors adapt to Obsidian theme. Use explicit styles for consistent appearance across themes.
19
20**Performance**: Very large diagrams (50+ nodes) may slow down rendering. Split into multiple diagrams if needed.
21
22**Export**: PDF export converts diagrams to images. For external sharing, capture as PNG/SVG.
23
24**No JavaScript**: Click events and JavaScript callbacks are disabled for security.
25
26---
27
28## Diagram Selection Guide
29
30| Use Case | Diagram Type | Keyword |
31|----------|--------------|---------|
32| Process flow, decision trees | Flowchart | `flowchart` |
33| API calls, message passing | Sequence | `sequenceDiagram` |
34| OOP design, relationships | Class | `classDiagram` |
35| Project timeline, scheduling | Gantt | `gantt` |
36| State machine, lifecycle | State | `stateDiagram-v2` |
37| Git branching strategy | Gitgraph | `gitGraph` |
38| Brainstorming, hierarchies | Mindmap | `mindmap` |
39| Proportions, percentages | Pie Chart | `pie` |
40| Database schema, entities | ER Diagram | `erDiagram` |
41| User experience steps, satisfaction | User Journey | `journey` |
42| Historical events, milestones | Timeline | `timeline` |
43| Priority matrix, 2D positioning | Quadrant Chart | `quadrantChart` |
44| Flow visualization, proportional bands | Sankey Diagram | `sankey-beta` |
45| Numerical data visualization | XY Chart | `xychart-beta` |
46| Precise element positioning, layouts | Block Diagram | `block-beta` |
47| Cloud services, service relationships | Architecture | `architecture-beta` |
48
49---
50
51## Quick Start Examples
52
53### Flowchart
54
55```mermaid
56flowchart TD
57 A[Start] --> B{Decision}
58 B -->|Yes| C[Action 1]
59 B -->|No| D[Action 2]
60 C --> E[End]
61 D --> E
62```
63
64**Key syntax:**
65- Direction: `TD` (top-down), `LR` (left-right), `BT`, `RL`
66- Shapes: `[rect]`, `(rounded)`, `{diamond}`, `[(cylinder)]`, `((circle))`
67- Arrows: `-->`, `-.->` (dotted), `==>` (thick)
68- Labels: `-->|text|` or `-- text -->`
69
70For details: [flowchart.md](flowchart.md)
71
72---
73
74### Sequence Diagram
75
76```mermaid
77sequenceDiagram
78 participant C as Client
79 participant S as Server
80 participant D as Database
81
82 C->>S: HTTP Request
83 activate S
84 S->>D: Query
85 D-->>S: Result
86 S-->>C: Response
87 deactivate S
88```
89
90**Key syntax:**
91- Arrows: `->>` (sync), `-->>` (response), `-)` (async)
92- Activation: `activate`/`deactivate` or `+`/`-` suffix
93- Control: `loop`, `alt`/`else`, `opt`, `par`/`and`, `critical`
94- Notes: `Note right of A: text`, `Note over A,B: text`
95
96For details: [sequence.md](sequence.md)
97
98---
99
100### Class Diagram
101
102```mermaid
103classDiagram
104 class Animal {
105 +String name
106 +int age
107 +makeSound() void
108 }
109 class Dog {
110 +fetch() void
111 }
112 Animal <|-- Dog : extends
113```
114
115**Key syntax:**
116- Visibility: `+` public, `-` private, `#` protected, `~` package
117- Relations: `<|--` inheritance, `*--` composition, `o--` aggregation, `-->` association
118- Methods: `+method(args) returnType`
119
120For details: [class-diagram.md](class-diagram.md)
121
122---
123
124### Gantt Chart
125
126```mermaid
127gantt
128 title Project Timeline
129 dateFormat YYYY-MM-DD
130
131 section Planning
132 Requirements :a1, 2024-01-01, 7d
133 Design :a2, after a1, 5d
134
135 section Development
136 Implementation :2024-01-15, 14d
137 Testing :7d
138```
139
140**Key syntax:**
141- `dateFormat`: Date format (YYYY-MM-DD, etc.)
142- Tasks: `name :id, start, duration` or `name :after id, duration`
143- Modifiers: `done`, `active`, `crit`, `milestone`
144
145For details: [gantt.md](gantt.md)
146
147---
148
149### State Diagram
150
151```mermaid
152stateDiagram-v2
153 [*] --> Idle
154 Idle --> Processing : start
155 Processing --> Success : complete
156 Processing --> Error : fail
157 Success --> [*]
158 Error --> Idle : retry
159```
160
161**Key syntax:**
162- Start/End: `[*]`
163- Transition: `State1 --> State2 : event`
164- Composite: `state Name { ... }`
165- Fork/Join: `state fork_name <<fork>>`, `<<join>>`
166
167For details: [state.md](state.md)
168
169---
170
171### Gitgraph
172
173```mermaid
174gitGraph
175 commit id: "init"
176 branch develop
177 checkout develop
178 commit id: "feat-1"
179 commit id: "feat-2"
180 checkout main
181 merge develop id: "v1.0" tag: "release"
182```
183
184**Key syntax:**
185- `commit`: Add commit, optional `id:`, `tag:`, `type:`
186- `branch name`: Create branch
187- `checkout name`: Switch branch
188- `merge name`: Merge branch
189
190For details: [gitgraph.md](gitgraph.md)
191
192---
193
194### Mindmap
195
196```mermaid
197mindmap
198 root((Project))
199 Frontend
200 React
201 TypeScript
202 Backend
203 Node.js
204 PostgreSQL
205 DevOps
206 Docker
207 CI/CD
208```
209
210**Key syntax:**
211- Indentation defines hierarchy
212- Shapes: `root((circle))`, `(rounded)`, `[square]`, `))cloud((`
213- Use 4-space or tab indentation
214
215For details: [mindmap.md](mindmap.md)
216
217---
218
219### Pie Chart
220
221```mermaid
222pie showData
223 title Browser Market Share
224 "Chrome" : 65
225 "Safari" : 19
226 "Firefox" : 8
227 "Edge" : 5
228 "Other" : 3
229```
230
231**Key syntax:**
232- `title`: Optional chart title
233- `showData`: Display values on segments
234- Format: `"Label" : value`
235
236For details: [pie.md](pie.md)
237
238---
239
240### ER Diagram
241
242```mermaid
243erDiagram
244 CUSTOMER ||--o{ ORDER : places
245 ORDER ||--|{ LINE-ITEM : contains
246 CUSTOMER {
247 int id PK
248 string email UK
249 string name
250 }
251```
252
253**Key syntax:**
254- Entities: `ENTITY_NAME`
255- Attributes: `type name [PK/FK/UK]`
256- Cardinality: `||--o{` (one to many), `||--||` (one to one)
257- Relationship: `ENTITY1 REL ENTITY2 : label`
258
259For details: [er-diagram.md](er-diagram.md)
260
261---
262
263### User Journey
264
265```mermaid
266journey
267 title Customer Support
268 section Contact
269 Submit ticket: 2: Customer
270 Receive notice: 4: Agent
271 section Resolution
272 Troubleshoot issue: 3: Agent
273 Confirm solution: 5: Customer
274```
275
276**Key syntax:**
277- Sections: `section name`
278- Tasks: `Task name: score: actor`
279- Score: 1-5 (1 = unsatisfied, 5 = satisfied)
280- Actors: User roles involved
281
282For details: [journey.md](journey.md)
283
284---
285
286### Timeline
287
288```mermaid
289timeline
290 title Product Roadmap
291 section 2023
292 Q1 2023 : MVP launch
293 Q4 2023 : v1.0 release
294 section 2024
295 Q2 2024 : Major features
296 Q4 2024 : v2.0
297```
298
299**Key syntax:**
300- Time periods: `period : event`
301- Sections: Group related periods
302- Multiple events: `period : event1 : event2`
303- Flexible format: Years, months, quarters, or custom text
304
305For details: [timeline.md](timeline.md)
306
307---
308
309### Quadrant Chart
310
311```mermaid
312quadrantChart
313 title Feature Prioritization
314 x-axis Effort --> Value
315 y-axis Complexity --> Impact
316 Dark Mode: [0.4, 0.7]
317 Search: [0.6, 0.8]
318 Export PDF: [0.7, 0.6]
319 Fix UI Bug: [0.2, 0.3]
320```
321
322**Key syntax:**
323- Axes: `x-axis label --> label` and `y-axis label --> label`
324- Points: `Name: [x, y]` (coordinates 0.0-1.0)
325- Quadrants: Auto-divided at 0.5 on both axes
326
327For details: [quadrant-chart.md](quadrant-chart.md)
328
329---
330
331### Sankey Diagram
332
333```mermaid
334sankey-beta
335
336A,B,10
337A,C,15
338B,D,8
339C,D,22
340```
341
342**Key syntax:**
343- CSV format: `source, target, value`
344- Three columns required
345- Values are numeric (flow magnitude)
346- Nodes auto-created from sources/targets
347
348For details: [sankey.md](sankey.md)
349
350---
351
352### XY Chart
353
354```mermaid
355xychart-beta
356 title "Sales Data"
357 x-axis [Jan, Feb, Mar, Apr, May]
358 y-axis "Revenue" 0 --> 100
359 line [30, 45, 55, 70, 85]
360```
361
362**Key syntax:**
363- Chart type: `xychart-beta` or `xychart-beta horizontal`
364- X-axis: `[categories]` or `min --> max`
365- Y-axis: `"label" min --> max`
366- Series: `line [values]` or `bar [values]`
367
368For details: [xychart.md](xychart.md)
369
370---
371
372### Block Diagram
373
374```mermaid
375block-beta
376 columns 2
377 A["Frontend"]:1
378 B["Backend"]:1
379 C["Database"]:2
380
381 style A fill:#e3f2fd,stroke:#1565c0,color:#0d47a1
382 style B fill:#f3e5f5,stroke:#7b1fa2,color:#4a148c
383 style C fill:#e8f5e9,stroke:#2e7d32,color:#1b5e20
384```
385
386**Key syntax:**
387- Blocks: `ID["Label"]:SPAN` - Each block on new line
388- Columns: `columns N` - Define layout width
389- Styling: `style ID fill:#hex,stroke:#hex,color:#hex`
390- Spans: `:N` suffix - How many columns block occupies
391
392For details: [block.md](block.md)
393
394---
395
396### Architecture Diagram
397
398```mermaid
399architecture-beta
400 group Cloud(cloud)[Cloud Infrastructure]
401 service web(server)[Web Server] in Cloud
402 service api(server)[API Server] in Cloud
403 service db(database)[Database]
404
405 web:R --> L:api
406 api:R --> L:db
407```
408
409**Key syntax:**
410- Groups: `group {id}({icon})[{label}]` - Organize services
411- Services: `service {id}({icon})[{label}] (in {parent})?` - Available icons: server, database, cloud, disk, internet
412- Nesting: `in {parent_id}` - Place service/group inside parent group
413- Connections: `{id1}:{pos} {arrow} {pos}:{id2}` - Position: L(eft), R(ight), T(op), B(ottom)
414- Arrows: `-->` (right), `<--` (left), `--` (both)
415
416For details: [architecture.md](architecture.md)
417
418---
419
420
421## Common Patterns
422
423### Adding Styles
424
425```mermaid
426flowchart LR
427 A[Normal] --> B[Styled]
428 style B fill:#f96,stroke:#333,stroke-width:2px
429```
430
431### Using Classes
432
433```mermaid
434flowchart LR
435 A:::highlight --> B --> C:::highlight
436 classDef highlight fill:#ff0,stroke:#f00,stroke-width:2px
437```
438
439### Comments
440
441```mermaid
442flowchart TD
443 %% This is a comment
444 A --> B
445```
446
447---
448
449## Reference
450
451For complete documentation on common features:
452- [reference.md](reference.md) - Styling, themes, comments, directives
453
454For diagram-specific guides:
455- [flowchart.md](flowchart.md) - Node shapes, links, subgraphs
456- [sequence.md](sequence.md) - Messages, activation, control flow
457- [class-diagram.md](class-diagram.md) - Classes, relationships
458- [gantt.md](gantt.md) - Tasks, dependencies, milestones
459- [state.md](state.md) - States, transitions, composite states
460- [gitgraph.md](gitgraph.md) - Commits, branches, merges
461- [mindmap.md](mindmap.md) - Hierarchies, node shapes
462- [pie.md](pie.md) - Proportional data
463- [er-diagram.md](er-diagram.md) - Entities, attributes, relationships (Session 1)
464- [journey.md](journey.md) - User journeys, satisfaction scores (Session 1)
465- [timeline.md](timeline.md) - Events, milestones, time periods (Session 1)
466- [quadrant-chart.md](quadrant-chart.md) - Priority matrix, 2D positioning (Session 2)
467- [sankey.md](sankey.md) - Flow visualization, proportional bands (Session 2)
468- [xychart.md](xychart.md) - Numerical data visualization (Session 2)
469- [block.md](block.md) - Element positioning, multi-column layouts (Session 3)
470- [architecture.md](architecture.md) - Cloud services, service relationships (Session 3)