Edit

Writing diagrams

The editor speaks Mermaid, a short text language for diagrams. Every Mermaid diagram type works: flowcharts, sequence, class, state, and ER diagrams, Gantt charts, mind maps, timelines, architecture diagrams, and more. The styling controls apply most fully to flowcharts, and Manual mode edits flowcharts, state, sequence, ER, and class diagrams on the canvas.

Mermaid in a minute

Five lines make a flowchart:

  1. The first line names the diagram type and, for a flowchart, its direction: flowchart LR runs left to right, flowchart TD top down.
  2. Each box has an id and a label: A[Order placed]. The brackets set the shape: [ ] a box, ( ) rounded, { } a decision, (( )) a circle.
  3. An arrow joins two ids: A --> B. Put a label on it with -->|yes|. -.-> draws a dotted line and ==> a thick one.
  4. Reuse an id to point at the same box again: B -->|no| D[Send reminder].
  • Wrap a label in quotes when it has brackets or other punctuation: A["Pay (card)"].
  • Group boxes with subgraph Payments … end.
  • A line starting %% is a comment, which the drawing ignores.
  • Indenting is optional, but makes the code easier to read.
order-flow.mmd
flowchart LR
  A[Order placed] --> B{Paid?}
  B -->|yes| C[Ship order]
  B -->|no| D[Send reminder]
  C --> E((Done))

Other types start with their own first line:

Quadrant charts, Sankey, XY and block diagrams, packet diagrams, Kanban boards, requirement and C4 diagrams work too. Cards with icons, subtitles, and badges are written inside ordinary labels: see Rich nodes and icons. For every type’s full syntax, see the Mermaid reference.

Start a blank flowchart and type it line by line: each box appears as you go.

While you type

  • The canvas redraws a quarter of a second after you stop typing. Keywords, labels, arrows, and comments are coloured, and brackets and quotes close themselves.
  • When the text can’t be read, the status bar says 1 error, and the canvas keeps the last good drawing, marked Showing the last valid version. Under the code, a red box names the line, such as Syntax error on line 5, quotes Mermaid’s message, and offers Go to line 5, which puts the cursor there. The line is also marked in red beside the code.
  • Fix the line and the status bar says Valid again.
  • Very large diagrams can take a while. Drawing took too long means try again; Drawing stopped responding means reload the page. Your code is kept either way.

The status bar at the bottom of the editor shows, from the left:

  • Valid, Rendering, or 1 error.
  • The diagram type, and for flowcharts the number of nodes and edges.
  • The cursor’s line and column, such as Ln 4, Col 12.
  • Gen AI icons need Pro, when the diagram uses icons your plan doesn’t include (see Icon libraries).
  • The layout engine, such as ELK layered or Dagre (see Layout).
  • Where your work is saved: Stored in this browser or Saved to your account. Storage full means the browser has no room left: download a backup and delete what you don’t need, or sign in.
  • Help, which opens the help assistant.

If it doesn’t work: the usual causes are an arrow with nothing after it, brackets that don’t pair up, or quotes inside a label (wrap the whole label in "…" instead). Mermaid names the line where it gave up, which can be the line after the mistake, so check the line above too.

A mistake shows 1 error and keeps the last drawing; Go to line finds it, and fixing it redraws.

The code panel

The bar above the code shows the diagram’s file name (its name with .mmd) and four buttons:

  • Rich node opens the builder for a card with an icon, subtitle, badges, and status, and inserts it below the cursor (see The rich node builder). The Rich node and icon builder button in the left rail opens it too.
  • The bookmark, Save selection as snippet, keeps the flowchart nodes in the lines you selected, to insert in any flowchart (see Snippets).
  • Copy Mermaid code copies all of the code.
  • Reset code to the template puts back the code the diagram started from: its built-in template, or the blank flowchart. It asks first, and Ctrl + Z undoes it. A diagram that started another way (opened from a file, made with the AI, from a SQL schema or one of your templates) has nothing to go back to, so the button is greyed out and says why.
  1. To make the panel wider or narrower, drag its right edge. Or press Tab until the edge is outlined, then use the arrow keys; hold Shift for bigger steps. It stays between 280 and 800 pixels, and never takes more than 60% of the window.
  2. To give the canvas the whole width, choose Hide code at the top right of the editor, or Code in the left rail. Choose either again to bring it back.
  3. Hide inspector, beside it, hides the style panel on the right.

On a phone, or a window narrower than a tablet, the editor shows one panel at a time. Tabs under the top bar switch between Code, Diagram and Style; it opens on the diagram, and a red dot on Code means the code has an error.

To replace the code with a built-in template, use Templates in the top bar (see Templates).

Drag the code panel’s edge to resize it, and use Hide code to give the canvas the room.

Shortcuts

In the code editor (on a Mac, use ⌘ for Ctrl and ⌥ for Alt):

  • Ctrl + Z undoes and Ctrl + Y (on a Mac, ⌘ + Shift + Z) redoes. The Undo and Redo buttons in the top bar do the same.
  • Ctrl + / turns the selected lines into %% comments, or back.
  • Ctrl + F finds text in the code; Ctrl + H finds and replaces (on a Mac, ⌥ + ⌘ + F).
  • Alt + ↑ or ↓ moves the current line up or down.
  • Ctrl + D selects the next match of the selected text, to change several at once.

Elsewhere:

  • / on the Projects page goes to the search box; Esc clears it.
  • Esc closes dialogs and menus.
  • In Manual mode, Delete removes what’s selected on the canvas, Esc clears the selection, and undo and redo work there too.
Press Ctrl + / to comment out a line, and Ctrl + F to find text in the code.