> ## Documentation Index
> Fetch the complete documentation index at: https://craft-support.mintlify.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Mermaid Diagrams

> Use Mermaid to create flowcharts, sequence diagrams, ER diagrams, and other text-based diagrams in Craft.

Craft supports Mermaid diagrams — a way to create visual diagrams by writing simple text syntax. Type a few lines of code, and Craft renders it as a crisp, sharp diagram right inside your document.

Diagrams update live as you type, work across all platforms, and render on shared and published pages.

<img src="https://mintcdn.com/craft-support/ivoQJBaJTefk9e0t/images/write-and-edit/mermaid-diagrams/en/content/flowchart-preview.png?fit=max&auto=format&n=ivoQJBaJTefk9e0t&q=85&s=db14d9fa849df0904c0cc4c051e19905" alt="A Mermaid flowchart rendered in a Craft document" width="1498" height="991" data-path="images/write-and-edit/mermaid-diagrams/en/content/flowchart-preview.png" />

## Inserting a Mermaid Diagram

Add a Mermaid diagram using one of these methods:

* Type `/mermaid` and select **Mermaid Diagram**
* Choose **Mermaid Diagram** from the **Insert** panel in the sidebar (under Rich Blocks)
* Paste markdown containing a ` ```mermaid ` code fence — Craft converts it automatically

## Editing

When you open a Mermaid block, it shows a split view — the rendered diagram on top, your code below. The preview updates live as you type.

<img src="https://mintcdn.com/craft-support/ivoQJBaJTefk9e0t/images/write-and-edit/mermaid-diagrams/en/content/split-view-editing.png?fit=max&auto=format&n=ivoQJBaJTefk9e0t&q=85&s=894c6b5397d22b4673f1aecf7de6e11c" alt="Split view with diagram preview on top and code editor below" width="1498" height="991" data-path="images/write-and-edit/mermaid-diagrams/en/content/split-view-editing.png" />

<Tabs>
  <Tab title="macOS">
    Click the Mermaid block to open it in split view. The diagram preview appears on top with the code editor below. Double-tap the preview to zoom in.
  </Tab>

  <Tab title="iOS / iPad">
    Tap the block to open the code editor with a live preview above. On iPhone, dismiss the keyboard to see the diagram. Double-tap the preview to zoom.
  </Tab>

  <Tab title="Web / Windows">
    Click the block to edit. Use the view mode menu in the block's context menu to switch between Edit, Preview, and Split View.
  </Tab>
</Tabs>

<Tip>
  You don't need to know Mermaid syntax by heart — the Craft AI Assistant can generate diagrams for you. Just describe what you want and it will write the code.
</Tip>

## Supported Diagram Types

### Flowcharts

Map out processes, decisions, and workflows. Use `graph TD` for top-down or `graph LR` for left-to-right layouts.

```
graph TD
    A[Start] --> B{Decision}
    B -->|Yes| C[Do This]
    B -->|No| D[Do That]
    C --> E[Done]
    D --> E
```

### Sequence Diagrams

Show interactions between people or systems over time.

<img src="https://mintcdn.com/craft-support/ivoQJBaJTefk9e0t/images/write-and-edit/mermaid-diagrams/en/content/sequence-diagram.png?fit=max&auto=format&n=ivoQJBaJTefk9e0t&q=85&s=f75ca4347237c5fe789fb65a48060ca2" alt="A sequence diagram showing a food delivery flow" width="1473" height="927" data-path="images/write-and-edit/mermaid-diagrams/en/content/sequence-diagram.png" />

```
sequenceDiagram
    User->>App: Place order
    App->>Payment: Charge card
    Payment-->>App: Confirmed
    App-->>User: Order placed
```

### State Diagrams

Visualize how something transitions between states — perfect for order tracking, workflows, or processes.

<img src="https://mintcdn.com/craft-support/ivoQJBaJTefk9e0t/images/write-and-edit/mermaid-diagrams/en/content/state-diagram.png?fit=max&auto=format&n=ivoQJBaJTefk9e0t&q=85&s=6700ddefd98c2df1c74175826f6d65e4" alt="A state diagram showing an order lifecycle" width="1473" height="927" data-path="images/write-and-edit/mermaid-diagrams/en/content/state-diagram.png" />

```
stateDiagram-v2
    [*] --> Draft
    Draft --> Review
    Review --> Published
    Review --> Draft : Needs changes
    Published --> [*]
```

### Class Diagrams

Show the structure of a system — what things exist, their properties, and how they relate.

```
classDiagram
    class Document {
        +String title
        +Date created
        +publish()
    }
    class Folder {
        +String name
        +getDocuments()
    }
    Folder "1" --> "*" Document : contains
```

### ER Diagrams

Model data relationships — great for database design and planning.

```
erDiagram
    AUTHOR ||--o{ POST : writes
    POST ||--o{ COMMENT : has
```

### Charts

Create bar charts, line charts, or a combination of both.

```
xychart-beta
    title "Monthly Revenue ($K)"
    x-axis [Jan, Feb, Mar, Apr, May, Jun]
    y-axis "Revenue" 0 --> 120
    bar [45, 62, 78, 55, 89, 105]
```

## Changing the Theme

Mermaid diagrams adapt to your code editor theme. To change the look, tap the **paintbrush icon** in the toolbar and choose a theme — options include Tokyo Night, Dracula, Nord, GitHub, and more.

The diagram updates instantly. Diagrams also respect your document's light or dark mode.

<img src="https://mintcdn.com/craft-support/ivoQJBaJTefk9e0t/images/write-and-edit/mermaid-diagrams/en/content/theme-light.png?fit=max&auto=format&n=ivoQJBaJTefk9e0t&q=85&s=1d50b09075c75df863b7a97c39a86a9b" alt="Mermaid diagram in light theme" width="1473" height="927" data-path="images/write-and-edit/mermaid-diagrams/en/content/theme-light.png" />

<img src="https://mintcdn.com/craft-support/ivoQJBaJTefk9e0t/images/write-and-edit/mermaid-diagrams/en/content/theme-dark.png?fit=max&auto=format&n=ivoQJBaJTefk9e0t&q=85&s=fb81678ca8d061283a3e7afc87e4a69b" alt="Mermaid diagram in dark theme" width="1473" height="927" data-path="images/write-and-edit/mermaid-diagrams/en/content/theme-dark.png" />

## Sharing and Publishing

Mermaid diagrams render on shared and published pages — anyone viewing the link sees the rendered diagram, not the code. No special setup needed.

## Importing and Exporting

* **Markdown import**: Paste or import markdown with ` ```mermaid ` code fences and Craft creates Mermaid blocks automatically.
* **Markdown export**: Mermaid blocks export as standard ` ```mermaid ` code fences, compatible with other tools.

## Tips

<AccordionGroup>
  <Accordion title="What if my diagram shows 'Invalid Mermaid diagram'?">
    This usually means a syntax error in your code. Check for typos or missing arrows. If you're copying syntax from another tool, note that Craft supports flowcharts, sequence diagrams, state diagrams, class diagrams, ER diagrams, and XY charts — other types like pie charts, Gantt charts, or mindmaps are not currently supported.
  </Accordion>

  <Accordion title="Can the AI Assistant help write Mermaid diagrams?">
    Yes. Describe the diagram you want and the Craft AI Assistant will generate the Mermaid code for you. You can also ask it to modify or extend an existing diagram.
  </Accordion>

  <Accordion title="Can I zoom into a large diagram?">
    On Mac and iPad, double-tap the diagram preview to zoom in. On the web, use the fullscreen view for larger diagrams.
  </Accordion>
</AccordionGroup>

<Info title="Learn Mermaid syntax">
  Mermaid is an open standard used across many tools. Visit [mermaid.js.org](https://mermaid.js.org/intro/) to learn the full syntax for each diagram type.
</Info>
