Draw diagrams in a note with Mermaid
A diagram in a note is usually a screenshot from another app, which goes stale the first time the plan changes. Mermaid keeps the diagram as text instead. You describe the boxes and arrows in a code block, and Loam draws them in place. To change the diagram, you edit a line.
Diagrams render in the desktop app, the web app and the iPhone, iPad and Android apps.
Add your first diagram
Open a code block with three backticks followed by the word mermaid, write the diagram, and close the block with three more backticks:
```mermaid
flowchart TD
A[New idea] --> B{Worth a note?}
B -- Yes --> C[Write it down]
B -- No --> D[Let it go]
```
When the cursor leaves the block, the code gives way to the drawing. Click or arrow back into it and the source returns, with the diagram drawn underneath, so you can edit a line and watch the result update. If you turn off Hide Markdown in Settings › Editor, the source and the diagram stay on screen together.
The first line of the block names the kind of diagram. Here flowchart TD means a flowchart that runs top down. flowchart LR runs left to right, which suits a short chain of steps.
Which diagrams you can draw
Loam draws diagrams with Pele, a Mermaid renderer that supports the diagram types built into Mermaid 12.1.0. These all render in Loam:
- Flowcharts, with
flowchart - Sequence diagrams, with
sequenceDiagram - State diagrams, with
stateDiagram-v2 - Class diagrams, with
classDiagram - Entity relationship diagrams, with
erDiagram - Gantt charts, with
gantt - Pie charts, with
pie - Mind maps, with
mindmap - Timelines, user journeys, git graphs and kanban boards, with
timeline,journey,gitGraphandkanban
Mermaid’s own documentation has the full syntax for each one.
Three diagrams worth keeping in a note
Show who talks to whom. A sequence diagram suits an API call, a hand-off between teams or the steps of a sign-in:
```mermaid
sequenceDiagram
participant App
participant Server
App->>Server: Save note
Server-->>App: Saved
```
Plan work over days. A Gantt chart turns a list of tasks into a schedule. The after a1 part starts a task when task a1 ends:
```mermaid
gantt
title Mast install
dateFormat YYYY-MM-DD
section Roof
Mount bracket :a1, 2026-11-24, 2d
Raise mast :after a1, 1d
```
Map the states something moves through. A state diagram shows a draft going through review:
```mermaid
stateDiagram-v2
[*] --> Draft
Draft --> Review
Review --> Draft
Review --> Done
Done --> [*]
```
Colours follow your theme
You never set colours. The diagram takes its background, text, lines and accent from the editor theme you picked, so it looks right in each of the 22 themes. When the theme changes, for example when Automatic follows your system into dark mode, the diagram changes with it.
Diagrams don’t load pictures from the web.
Fix a diagram that won’t draw
If Mermaid can’t read the text, the block shows the error’s first line in place of the diagram. A missing node after an arrow gives Parse error on line 2:, and a first line that doesn’t name a diagram type says that no diagram type was detected. Open the block, correct that line and the drawing appears.
A few habits keep diagrams easy to maintain:
- Give each box a short label. Long sentences make wide shapes that are hard to read on a phone.
- Keep one idea per diagram. When a flowchart passes a dozen boxes, split it into two blocks.
- Put the diagram below one line of plain text that says what it shows, so the note still makes sense to a reader who only sees the text, such as on a published page.
On iPhone, iPad and Android
Type the block the same way. A diagram draws in the note once you move out of it. Tapping back into the block shows the source, so editing works as it does on a computer.
What readers of a published page see
A published page is read-only, and it shows a Mermaid block as its source code rather than a drawing. If you want readers to see the diagram itself, they need to open the note in Loam. Publishing is a Loam Pro feature, and only the note’s owner can turn it on.
Diagrams are free on every plan. Loam Pro adds sync across devices, collaboration, full version history, AI agents and publishing.
Related
Get new posts in your feed reader. Subscribe with RSS