or go to full-text search page →

Search

Search IconIcon to open search

Mermaid

Last updatedUpdated: by Simon Späti · 5 min read · evergreen Note status Evergreen. Own words, refined over time. Still grows. Estimated from edit history · 17 sessions over 2 years · 1,031 words · How my notes grow Recent changes 2 weeks ago +128 / −0 words 7 weeks ago +159 / −3 words 9 months ago +0 / −1 words 9 months ago +20 / −3 words 2 years ago +159 / −0 words 2 years ago +71 / −0 words 2 years ago +2 / −0 words 2 years ago +181 / −0 words 2 years ago +63 / −0 words 2 years ago +3 / −0 words 2 years ago +49 / −0 words 2 years ago +25 / −0 words 3 years ago +1 / −0 words 3 years ago +114 / −2 words 3 years ago +31 / −2 words 3 years ago new · 12 words 3 years ago new · 12 words

JavaScript-based diagramming and charting tool that renders Markdown-inspired text definitions to create and modify diagrams dynamically.

Generate images like below with just text:

Making it git and collaboration ready.

A simple example you can see inDAG.

# Why I Use it

I am a technical author, and I love writing, but I don’t like creating diagrams. I’ve been using Markdown for many, many years, and for a couple of years, all my diagrams have been created based on Mermaid. I love it; not only can I update and maintain images better in my second brain and articles or even in my book by updating them quickly (change a typo or search-replace).

I can also generate an initial Mermaid based on the article I have written. And then add my ideas to it. I recommend it to anyone. I also use  Mermaid Charts to beautify Mermaid if I need to publish somewhere else as an image. Just paste the mermaid and choose the style. PS: For more complex diagrams I have found PlantUML works great too. But I love Mermaid for its simplicity, and it works out of the box on all my websites, too. Reddit

# Configs (Vertical/Horizontal)

  • TD or TB: This declares the flowchart is oriented from top to bottom
  • LR: Horizontal

More on About Mermaid.

# Charts

# Examples

# Bar Chart

gantt
    title Gantt Chart with Mermaid
    dateFormat X
    axisFormat %s
    section Apple
    Apple   : 0, 100
    section Bananas
    75   : 0, 75
    section Oranges
    150   : 0, 150
  
gantt
    title Gantt Chart with Mermaid
    dateFormat X
    axisFormat %s
    Apple   : 0, 100
    Bananas   : 0, 75
    Oranges   : 0, 150
  

# Flow

Apparently, Mermaid can also showcase database objects as shown here:

graph TD
    USER(User) -->|uses| VIEW(View)
    VIEW -->|sees| CONTROLLER(Controller)
    CONTROLLER -->|manipulates| MODEL(Model)
    CONTROLLER -->|requests| SEMANTIC(Semantic Layer)
    SEMANTIC -->|applies business logic| MODEL
    MODEL -->|updates| VIEW
    SEMANTIC -->|abstracts data access| VIEW
    MODEL -->|stores data| Database

    Database[(Database)]
  

# SubGraphs

Kubernetes

# Different Arrows (Dotted, Text)

flowchart LR
    A1-->B1[Normal arrow]
    A2---B2[Open link]
    A3-- This is the text! ---B3[Text on open link]
    A4---|This is the text|B4[Alternative text on open link]
    A5-->|text|B5[Arrow with text]
    A6-- text -->B6[Alternative arrow with text]
    A7-.->B7[Dotted arrow]
    A8-. dotted text .->B8[Dotted with text]
    A9==>B9[Thick arrow]
    A10== thick text ==>B10[Thick with text]
    A11~~~B11[Invisible link]
  

More on Flowcharts Syntax | Mermaid.

# History

# V12 with New Visualizations (More Prettier)

bundled default layout engine, a new redux-color / neo default appearance, and two new diagram types: UML use case diagrams. Release mermaid@12.0.0

New even with moving parts:

Update

This works now 2026-10-24 also in Obsidian and on my page

usecase-beta
direction LR
accTitle: Online ordering use cases
accDescr {
  A customer places an order through the storefront.
  Staff review the order and inspect its data.
}
actor Customer("Customer")
actor Staff("Order staff")@{ type: hollow, business: true } <<Employee>>
systemBoundary ordering["Ordering System"]@{ type: package }:::system
  Browse("Browse products")
  Checkout("Checkout") <<Core>>:::critical
  Payment("Process payment")
  Review[Review order]
end
json OrderData@{
  "status": "pending",
  "items": [{ "name": "Book", "quantity": 1 }],
  "total": 29.95
}:::data
note for Checkout "`Validates the **cart** before payment`"
Customer starts@-- "places order" ---> Checkout
Customer --> Browse
Checkout pays@..> : include Payment
Staff --> Review
Review --> OrderData
classDef system stroke:#c8a02a,stroke-width:2px
classDef critical stroke:#c33,stroke-width:3px
classDef data stroke:#3572a5
starts@{ animation: fast }
style pays stroke:#6b46c1,stroke-width:2px
  

The mermaid code from Mermaid.ai:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
usecase-beta
direction LR
accTitle: Online ordering use cases
accDescr {
  A customer places an order through the storefront.
  Staff review the order and inspect its data.
}
actor Customer("Customer")
actor Staff("Order staff")@{ type: hollow, business: true } <<Employee>>
systemBoundary ordering["Ordering System"]@{ type: package }:::system
  Browse("Browse products")
  Checkout("Checkout") <<Core>>:::critical
  Payment("Process payment")
  Review[Review order]
end
json OrderData@{
  "status": "pending",
  "items": [{ "name": "Book", "quantity": 1 }],
  "total": 29.95
}:::data
note for Checkout "`Validates the **cart** before payment`"
Customer starts@-- "places order" ---> Checkout
Customer --> Browse
Checkout pays@..> : include Payment
Staff --> Review
Review --> OrderData
classDef system stroke:#c8a02a,stroke-width:2px
classDef critical stroke:#c33,stroke-width:3px
classDef data stroke:#3572a5
starts@{ animation: fast }
style pays stroke:#6b46c1,stroke-width:2px

# Troubleshoot

# Flow Positioning (Ordering)

I couldn’t bring human on top, rearranging does not help

%%{init: {'theme':'base'}}%%
graph TD

    subgraph "With GenBI"
        H2[👤 Human] -->|"Prompt"| AI[🧠 AI Model]
        AI -->|"Generate"| Preview[🔍 Preview]
        P2 -->|"Iterate"| H2
        Preview -->|"Ship"| P2[🚀 Production]
        Preview -->|"Refine"| H2
    end
  

This one has it:

%%{init: {'theme':'base'}}%%
graph TD

    subgraph "With GenBI"
        H2[HUMAN]
        AI[AI Model]
        PRE[Preview]
        P2[Production]
        
        H2 -->|Prompt| AI
        AI -->|Generate| PRE
        PRE -->|Ship| P2
        PRE -->|Refine| H2
        P2 -->|Iterate| H2
    end
  

The difference is

  1. Node Declaration vs Flow Declaration
  • The second diagram explicitly declares all nodes first, then defines connections separately:
1
2
3
4
5
6
H2[HUMAN] 
AI[AI Model] 
PRE[Preview] 
P2[Production] 

H2 -->|Prompt| AI
  • The first diagram combines node declaration with flow in one line:
1
H2[Human] -->|"Prompt"| AI[AI Model]`
  • By declaring nodes separately first (second diagram), Mermaid treats them as independent elements that can be positioned more freely
  • When nodes are declared within the flow (first diagram), Mermaid tries to optimize the flow direction, which can lead to different automatic positioning

# Pointing Subgraph to Outergraph

Ah, I understand the issue now. The error occurs because there’s a reference to Core as a direct node in MergeSCD2 --> Core, but Core is actually a subgraph. In Mermaid, you can’t directly connect to a subgraph - you need to connect to nodes within the subgraph.
TypeError: Cannot read properties of undefined (reading ‘x’) · Issue #5064 · mermaid-js/mermaid · GitHub

# Optimize Styling: Tools

# Alternatives

More powerful seems to be PlantUML, but Mermaid is the standard for Markdown and supported for most web like GitHub, Obsidian, Quartz, etc.


Origin:
Category: Writing & Reading