Mermaid Basics

2026-11-15

Mermaid draws diagrams from text: a few lines of code render into flowcharts, sequence diagrams and more. Insert a code block with the mermaid language in the editor.

Three rules

  1. The first line declares the diagram type — graph TD is a top-down flowchart;
  2. Nodes are a letter plus brackets (A[text]); arrows --> connect them;
  3. Lines starting with %% are comments and don't render.

The desktop renders automatically as you type the block; on mobile you edit the source and preview directly.

Flowchart

graph TD
    A[Wake up] --> B{Good weather?}
    B -- Yes --> C[Go for a run]
    B -- No --> D[Keep writing]

Square brackets are ordinary nodes, curly braces are decisions, and the label between the dashes on an arrow describes the branch.

Sequence diagram

sequenceDiagram
    Author->>Editor: writes an idea
    Editor-->>Author: autosaves

->> is a solid arrow, -->> a dashed one; the message follows the colon.

State diagram

stateDiagram-v2
    [*] --> Ideation
    Ideation --> Writing: new chapter
    Writing --> Revising: draft done
    Revising --> [*]

[*] marks start and end; the text after a colon on an arrow is the trigger.

More diagram types: Mermaid Charts Cheat Sheet.

When it doesn't render

Usually a typo: check the declaration line, make sure arrow symbols are complete, and look for stray special characters in node labels. Fix one thing at a time — faster than rewriting the block.