Skip to Content
ToDiagram

Mermaid Diagrams

Draw flowcharts, sequence diagrams and entity relationship diagrams from Mermaid text.

Write Mermaid in the text editor and ToDiagram draws it as you type. Flowcharts, sequence diagrams and entity relationship diagrams are supported. Files with the extension .mermaid or .mmd open as Mermaid.

Flowchart

flowchart LR
  A[logos:github-icon Push to main] --> B[logos:docker-icon Build]
  B --> C[logos:vitest Unit tests]
  B --> D[logos:eslint Lint]
  C --> E{All green?}
  D --> E
  E -- yes --> F[logos:kubernetes Deploy to staging]
  F --> G[logos:playwright Smoke tests]
  G --> H[logos:kubernetes Deploy to production]
  E -- no --> I[logos:slack-icon Notify team]
The flowchart above: a deploy pipeline from a push to main through build, tests and lint to staging and production, with a logo on each step
The flowchart above, drawn by the editor.

Open a Mermaid example in the editor

Sequence diagram

sequenceDiagram
  participant U as User
  participant W as Web app
  participant A as Auth API
  U->>W: Sign in
  W->>A: POST /token
  A-->>W: 200 access token
  W-->>U: Dashboard
The sequence diagram above: a user, a web app and an auth API exchanging four messages
The sequence diagram above, drawn by the editor.

Supported Syntax

Supported Mermaid syntax includes:

  • Flowchart: flowchart/graph directions (LR, TB, BT, RL), node shapes (see below), connections, and edge labels.
  • Sequence: sequenceDiagram with participants, message arrows, notes, activations, grouped blocks (loop, alt, opt, par, critical, break, rect), and autonumber.
  • Entity Relationship: erDiagram with entities, attribute blocks (types, PK/FK/UK keys, comments), relationships with cardinalities, direction, and subgraph grouping.

Entity Relationship Diagrams

Entities render as cards with one row per attribute. Relationships become labeled edges showing the role and cardinality of each side, and non-identifying relationships (written with ..) render as dashed lines.

erDiagram
  CUSTOMER ||--o{ ORDER : places
  ORDER ||--|{ LINE_ITEM : contains
  CUSTOMER {
    int id PK
    string name
    string email
  }
  ORDER {
    int id PK
    int customer_id FK
    date placed_at
  }
  LINE_ITEM {
    int order_id FK
    string sku
    int qty
  }
The entity relationship diagram above: customer, order and line item tables with their columns and the relationships between them
The entity relationship diagram above, drawn by the editor.

Cardinality symbols map to readable ranges on the edge label:

Symbol (left / right)MeaningLabel
|o / o|Zero or one0..1
|| / ||Exactly one1
}o / o{Zero or more0..N
}| / |{One or more1..N

Notes:

  • Every relationship requires a label (the : label suffix), per Mermaid's grammar.
  • Word forms such as one or more, zero or many, many(0), 1+, and only one are also supported.

Node Shapes

Mermaid's short-syntax flowchart shapes render as their declared silhouette:

Mermaid syntaxShape
A[text]Rectangle
A(text)Rounded rectangle
A([text])Stadium / pill
A[[text]]Subroutine
A[(text)]Cylinder
A((text))Circle
A(((text)))Double circle
A{text}Diamond
A{{text}}Hexagon
A[/text/]Parallelogram (lean right)
A[\text\]Parallelogram (lean left)
A[/text\]Trapezoid
A[\text/]Inverse trapezoid
A>text]Asymmetric
flowchart LR
    Start([Start]) --> Decide{Approved?}
    Decide -->|yes| Store[(PostgreSQL)]
    Decide -->|no| End(((Done)))
    Store --> End

Edges meet the outline of each shape, so connections touch circles, diamonds and hexagons cleanly.

Icons

Start a node's label with an Iconify icon name to put an icon on the node. The name has the form set:icon-name, for example lucide:database or logos:postgresql. A name that does not exist is not drawn.

flowchart LR
    A["lucide:monitor Web app"] --> B["lucide:database Database"]

Edit on the canvas

Flowcharts can be edited on the canvas as well as in the text: click a node for its details, right-click it for its toolbar, and use Swap direction in the canvas toolbar to switch between left to right and top to bottom. Every change is written back as Mermaid text. See Edit on the Diagram.

Entity relationship diagrams can be edited on the canvas too. In a sequence diagram you can double-click a message to change its text. The rest is edited as text.

Good to know

  • Views other than the flow diagram and the tree, Fields, Compare and JSON Schema apply to data formats and are not available for Mermaid.
  • Export works the same as for any other diagram: PNG, JPEG, SVG and MP4.

On this page