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