Mermaid live diagram editor and generator

Turn text into a diagram with the live editor below. Explore the guide and examples to choose the right diagram for a process, a technical explanation or a project plan.

Loading the tool…

What is Mermaid?

Mermaid is a diagramming language and renderer: you describe steps, people or relationships in text, and it draws the diagram. For example, Review --> Publish connects two nodes with an arrow. You write the relationships; Mermaid handles the layout.

This approach is often called diagrams as code. The source is ordinary text that you can search, copy and keep in version control alongside the document it explains. You do not need to write JavaScript to use it. Mermaid draws what you describe; it does not inspect your application or verify that a process is correct.

Choose a diagram for the question you need to answer

A useful diagram has a clear purpose. Decide what the reader needs to understand before choosing shapes or colors.

Your questionA useful diagramWhat to include
What happens next, and where can the process branch?FlowchartActions, decisions and outcomes, such as approving an expense.
Who talks to whom, and in what order?Sequence diagramPeople or services and their messages, such as an API request.
What can this item become?State diagramStates and transition events, such as opening, resolving and reopening a ticket.
How are our records related?Entity relationship diagramEntities, keys and cardinality, such as customers and orders.
What depends on what, and when can it happen?Gantt chartDates, durations and dependencies for a small project.

For other questions, a mind map can organize ideas, a timeline can summarize events, and a Git graph can explain a branching strategy. Start with the Mermaid syntax overview when choosing a family outside these examples. Each family has its own grammar; changing only the first line does not convert one diagram into another.

Five examples to adapt

Each tab contains a complete diagram and explains a modeling choice. Copy the code into a Mermaid editor to render it; the opening diagram declaration belongs in the source, while Markdown’s surrounding backticks do not.

Make the exception path visible

An expense approval process needs to explain what happens when a receipt is missing. This flowchart sends the request back for correction instead of leaving the rejection path unexplained.

flowchart TD
    Submit["Submit expense"] --> Check{"Receipt attached?"}
    Check -->|Yes| Review["Manager review"]
    Check -->|No| Fix["Attach receipt"]
    Fix --> Check
    Review --> Decision{"Approved?"}
    Decision -->|Yes| Pay["Reimburse employee"]
    Decision -->|No| Reject["Explain rejection"]

TD lays out the main flow from top to bottom; try LR for left to right. Check is a stable identifier, while the text inside quotes is the visible label. Keep identifiers when changing the wording so existing connections still point to the same nodes. Braces create decisions, and |Yes| labels an edge. The flowchart reference covers other shapes and grouping related steps into subgraphs.

Show what happens on a cache miss

A sequence diagram helps reviewers follow a request across components. This example makes a cache miss explicit: the API reads the database only when the cache has no result.

sequenceDiagram
    participant Browser
    participant API
    participant Cache
    participant DB as Database
    Browser->>API: GET /products/42
    API->>Cache: Look up product 42
    alt Cache hit
        Cache-->>API: Product
    else Cache miss
        Cache-->>API: Not found
        API->>DB: Read product 42
        DB-->>API: Product
        API->>Cache: Store product
    end
    API-->>Browser: 200 OK with product

Read messages from top to bottom. Here solid arrows represent requests and dashed arrows represent replies; alt and else describe alternative paths. Add another alternative if the product can also be absent from the database. The diagram describes an intended exchange, not measured response times or a test of the endpoint. See the sequence diagram reference for loops, notes and parallel interactions.

Separate an item’s state from the action that changes it

Use a state diagram when the important question is whether a transition is allowed. A ticket can be resolved and then reopened; closing it ends this example’s lifecycle.

stateDiagram-v2
    [*] --> Open
    Open --> InProgress: Assign
    InProgress --> Waiting: Request information
    Waiting --> InProgress: Receive reply
    InProgress --> Resolved: Provide solution
    Resolved --> Open: Reopen
    Resolved --> Closed: Confirm resolution
    Closed --> [*]

The labels after : name the events that trigger transitions. [*] marks the start or end, depending on the arrow’s direction. Ask the process owner whether reopening a closed ticket is allowed: if it is, the model needs another transition. A diagram can expose that unanswered question, but it cannot decide the rule. The state diagram reference also explains nested states.

State the relationship rules before listing every field

This small order model says a customer may have no orders, while each order must contain at least one line. It is useful for agreeing on those rules before implementing tables or API payloads.

erDiagram
    CUSTOMER ||..o{ ORDER : places
    ORDER ||--|{ ORDER_LINE : contains
    CUSTOMER {
        int id PK
        string email
    }
    ORDER {
        int id PK
        int customer_id FK
    }
    ORDER_LINE {
        int order_id PK, FK
        int line_number PK
        int quantity
    }

|| means exactly one, o{ means zero or more, and |{ means one or more. The dashed relationship makes an order independent of the customer’s identity; the solid relationship reflects order lines identified within an order. PK and FK annotate primary and foreign keys; they do not create database constraints. If empty draft orders are valid, change the order-line cardinality. Consult the entity relationship reference for the full notation.

Make dependencies visible in a small delivery plan

This schedule keeps drafting, review and publication in order. Changing the drafting duration moves the tasks that depend on it, making the knock-on effect easier to discuss.

gantt
    title Documentation release
    dateFormat YYYY-MM-DD
    excludes weekends
    section Preparation
    Outline       :outline, 2026-11-02, 2d
    Draft         :draft, after outline, 3d
    section Publication
    Review        :review, after draft, 2d
    Publish       :milestone, after review, 0d

draft and review are task identifiers; after draft refers to a dependency. With excludes weekends, durations skip weekend days, although the bars remain continuous across them. The dates are illustrative. This is a schedule drawing, not a resource planner: it does not know staff availability or enforce deadlines. The Gantt reference explains dates, exclusions and milestones.

Where Mermaid helps, and where it gets in the way

Mermaid is a good fit for diagrams that change with a specification, support article or codebase:

  • Changes are reviewable. A text diff can show that a step or relationship changed. Keep one relationship per line to make those reviews easier.
  • Updates can live beside the explanation. Store the diagram source with the document and review both in the same change. This helps maintenance, but does not keep the diagram current automatically.
  • You spend less time arranging shapes. Automatic layout is convenient for small process and interaction diagrams, especially when labels change often.

The tradeoffs matter just as much:

  • Precise placement is limited. Adding a connection can rearrange the drawing. If exact spacing, freehand annotation or a carefully composed illustration matters most, a visual drawing tool is usually a better fit.
  • Text editing has a learning curve. Missing punctuation or using another diagram family’s syntax can stop rendering. Start with a small working example and add one idea at a time.
  • Large diagrams become difficult to read. More nodes and crossed lines can obscure the point even when the source is valid. Split an overview from detailed workflows instead of shrinking everything onto one page.
  • Portability needs checking. A documentation platform may use another Mermaid version or different configuration. Test on the destination, especially when using recent syntax, icons or styling.

Put a diagram in a README or document

On a platform with Mermaid support, wrap the source in a fenced Markdown block labeled mermaid:

```mermaid
flowchart LR
    Draft --> Review --> Publish
```

GitHub’s diagram guide explains supported locations and how to check its Mermaid version. Other Markdown systems may need a plugin; an ordinary code fence alone does not make every renderer draw a diagram.

For slides or a document that cannot render Mermaid, insert an image and keep the source file alongside it. The image is a snapshot: changing the source later will not update an already inserted image. Review the result at its final display size, where long labels and small text can become unreadable.

Make the diagram useful to someone else

Give it a scope: “How a cache miss is handled” is more informative than “System architecture” for the API example above. Use verbs for actions, nouns for entities, and labels on decision paths. Include the failure or recovery path that readers are most likely to need.

Explain any important rule in nearby prose, and avoid making color the only way to distinguish outcomes. Mermaid’s accessibility options include accTitle and accDescr for an accessible title and description. When publishing a diagram as an image, add suitable alternative text in the destination document too; a PNG does not carry Mermaid’s SVG accessibility structure.

How to use this tool

  1. Choose Templates or paste Mermaid code into Diagram source. The preview updates after a short pause.
  2. Put the cursor on a line, then open Choose a block with the arrow beside Insert. Choosing a block inserts it; the main button repeats that choice. Edit its labels and connections in the source. Blocks use example names; connect them to your own nodes as needed.
  3. Use Undo and Redo in the main toolbar. The icons above the source indent, comment, duplicate, search or navigate. Navigate source lists nonempty source lines and lets you jump to a line number. Find and replace uses literal, case-sensitive text.
  4. Use Ctrl/Cmd+Z to undo, Ctrl/Cmd+Shift+Z to redo, Ctrl/Cmd+F to search, Ctrl/Cmd+/ to toggle comments and Ctrl/Cmd+[ or ] to change indentation. Use Move lines up/down or Alt+Up/Down to move the current line, or select several lines to move a whole block while retaining its indentation. The current line and selected lines stay highlighted when you use toolbar actions. Tab moves to the next control.
  5. The preview always starts with the light theme, regardless of the site theme; use the dotted theme link beside Live preview to choose another theme. Open Full screen preview from the right side of the preview toolbar. Each view keeps its own zoom. Hold Ctrl or Space and drag to pan a zoomed diagram, use Ctrl + wheel to zoom and Ctrl + 0 to fit. Ctrl + plus/minus also zooms when the preview is focused or in full screen (Ctrl + = works for zooming in too). Click the preview first for keyboard shortcuts; arrow keys also scroll it. Escape closes the full screen view and dialogs.
  6. Copy or download the source, or save the rendered diagram as PNG. If copying is unavailable, the source is selected for manual copying.

Templates and insert blocks

Templates and the 36 insert blocks cover twelve diagram families. Source rendering also accepts other types understood by the bundled Mermaid library. The Insert button resets to a useful default when the diagram family changes and otherwise remembers the last chosen block. Its menu opens one family at a time. Blocks from a different family are inserted as commented references; they do not convert the current diagram.

Saving, supported source and limits

PNG and source downloads are free. SVG export is reserved for a future premium plan and is hidden in the normal release. Subscriptions are not available yet.

Source stays in memory until you leave or reload the page. There is no automatic saving, account, sharing URL or AI service. Opening a file or loading a template replaces the current source and can be undone. Download your source before leaving.

Use up to 30,000 UTF-16 units, 600 lines and 250 edges. Complexity can reach the renderer’s practical limits sooner. PNG exports are capped at 4,096 pixels per side and approximately 12 million pixels. Preview zoom does not change export size.

Mermaid configuration directives, YAML front matter, shapes, style/classDef, theme settings and sanitized HTML labels are supported. Source configuration can override the toolbar’s default theme. Use Bootstrap icons with names such as bi:person or bi:database; the icon pack loads locally when needed. Image nodes accept embedded PNG, JPEG or WebP data URLs within the source limit.

Remote images, fonts and CSS imports are not loaded. Valid HTTP(S), email and fragment links are retained in SVG exports; the live preview and PNG are images, so their links are not clickable. Scripts, event handlers and unsafe URLs are removed, and source configuration cannot change security or resource limits. Mermaid errors may appear in English. An invalid or pending render clears the preview and disables image downloads so an older diagram is not mistaken for the current source.

Your tool data stays in your browser

This tool processes your data on your device. The text, files, or passwords you enter and the results it creates are not sent to our servers or any other server.

Page and asset requests still occur. Production pages also load Google Tag Manager, Cloudflare Web Analytics, and AdSense advertising; tool code does not send inputs or results to analytics or ads. See our privacy policy.

To inspect requests while using the tool, open your browser's developer tools and select Network. Try it with sample data.

Read How to Check Website Network Requests in Chrome, Firefox, Edge and Safari.

Premium is coming soon

An optional premium subscription to remove ads is planned. Subscriptions are not available yet.

You can keep using our free tools without an account.