What is a Mermaid editor?
Mermaid is a small text language for diagrams. You write a few lines such as A --> B and a renderer draws the boxes and arrows. Because the diagram is text, it lives happily in Git, reviews as a normal diff, and does not go stale in a screenshot nobody can edit. Many documentation tools and Markdown renderers already understand Mermaid.
This editor shows the diagram as you type. The text goes in on one side and the drawing updates on the other. It starts from ten templates: flowchart, sequence diagram, class diagram, state diagram, entity relationship (ER), Gantt chart, pie chart, mind map, user journey and Git graph. Pick one, change the words, and you have a diagram in a minute. Four themes are available (default, dark, forest and neutral), and you can save the result as SVG or PNG.
The Mermaid library runs in your browser, with the security level set to strict. In that mode text is escaped, and scripts, links and HTML in labels are removed. The diagram is drawn with labels as SVG text, not as HTML, which is what lets the same SVG be saved as a PNG. The side effect is that a label cannot contain HTML formatting. Nothing you write is sent to a server.
If the text is not valid, the tool shows the message from Mermaid instead of a blank screen, so you can find the line that needs fixing.
How to draw a diagram with Mermaid
- Choose "load a template" and pick the kind of diagram closest to what you need, or start typing in the input box.
- Edit the text. The first line names the diagram type, such as
flowchart TD,sequenceDiagramorgantt. - Watch the drawing update. If the text has an error, read the message and fix that line.
- Pick a theme: default, dark, forest or neutral. Use dark on a dark page, neutral for print.
- Save the diagram as SVG for documents and web pages, or as PNG for places that need a bitmap.
- Keep the Mermaid text in your repository. If your docs are in Markdown, you can turn them into a page with Markdown to HTML.
- For numbers rather than relationships, Chart maker draws bars, lines and pies from a table.
Examples
A flowchart with a decision
flowchart TD
A[Request] --> B{Valid?}
B -- yes --> C[Process]
B -- no --> D[Reject]
C --> E((Done))
D --> ETD means top down. Square brackets draw a box, braces a decision diamond and double parentheses a circle. The text on an arrow goes between dashes: -- yes -->.
A sequence diagram with an alternative
sequenceDiagram
participant U as User
participant A as API
participant D as Database
U->>A: POST /login
A->>D: find user
D-->>A: user
alt password ok
A-->>U: 200 token
else wrong password
A-->>U: 401
endSolid arrows (->>) are calls, dashed ones (-->>) are replies. The alt block draws the two outcomes as a labeled box.
A Gantt chart
gantt
title Release plan
dateFormat YYYY-MM-DD
section Build
Design :a1, 2026-11-23, 5d
Develop :after a1, 10d
section Ship
Test :2026-12-07, 4d
Release :milestone, 2026-12-11, 0dEach task has a start and a length. after a1 starts Develop when Design ends, and milestone marks a single day.
A pie chart in Mermaid
pie title Traffic by source
"Search" : 52
"Direct" : 28
"Social" : 20Mermaid shares are given as numbers and drawn as parts of the total.
Common mistakes
- A missing or misspelled first line. The diagram type must come first.
sequencediagramin the wrong case orflow chartwith a space is not recognized. - Special characters in labels. Parentheses, quotes and colons can confuse the parser. Put the label in double quotes, such as
A["Save (draft)"]. - Expecting HTML in labels. Under the strict setting, HTML is removed from labels and shown as text. Use plain text and line breaks the diagram type allows.
- Indentation that matters. A mind map uses indentation to nest branches. Mixing tabs and spaces gives a wrong tree.
- A huge diagram. Hundreds of nodes make an unreadable image. Split it into several diagrams.
- PNG fails in some browsers. The tool shows a message and suggests saving the SVG, which always works.
Frequently asked questions
Does the Mermaid editor upload my diagram?
No. The diagram is drawn in your browser and the text is never sent to a server.
Why does the tool use the strict security level?
Strict mode escapes the text and removes scripts, links and HTML from labels, so a diagram from an unknown source cannot run code on the page. The cost is that labels are plain text.
Can I use the diagram in a document?
Yes. Save the SVG, or the PNG, and insert it. You can also keep the Mermaid text next to the document, because it is smaller and easier to review than an image.
Where can I compress the PNG?
Use the image compressor. For tables turned into graphics, Chart maker is the better fit.