Mermaid Diagram Editor

Write Mermaid code, see the diagram as you type and export it as SVG or PNG.

About Mermaid Diagram Editor

Write Mermaid code and see the diagram as you type, with syntax errors shown by line, four themes, and SVG or PNG downloads made in the browser.

How to use

  1. Type or paste Mermaid code, or pick an example to start from: flowchart, sequence, class, state, entity relationship, Gantt or pie. Picking an example replaces the text in the editor.
  2. The preview redraws after a short pause in typing. If the code has a mistake, the line number and Mermaid's own message appear under the editor, and the last diagram that worked stays in view, faded.
  3. Choose a theme: Default, Dark, Neutral or Forest.
  4. Choose a white or transparent background, and a PNG scale of 1×, 2× or 3×. The PNG's size in pixels is shown under the scale.
  5. Download the SVG or the PNG.

What it does

  • Draws any diagram type the bundled Mermaid library supports. Mermaid is loaded only when this page opens, so other pages stay small.
  • Line numbers count from the top of the editor. Mermaid itself leaves front matter, %%{init}%% directives and %% comment lines out of its count; the page adds them back so the number matches what you see.
  • Uses Mermaid's strict security level, which encodes tags in labels and turns off click callbacks. HTML labels are off too, and a diagram's front matter or init directive cannot switch these back on. The preview is shown as an image, so nothing inside the SVG can run and its links cannot be followed.
  • A theme set in the diagram's own front matter or init directive takes priority over the theme buttons.
  • The SVG keeps text as text and is given a fixed width and height, so it opens at its natural size. The PNG is drawn from the same SVG, up to 8,192 pixels a side and 16.7 megapixels; a larger diagram at 3× is scaled down to fit and the page says so.
  • It does not save diagrams, make share links, draw several diagrams from one Markdown file, or let you move shapes by dragging. The text is not kept when you leave the page.

Example

flowchart TD
    A[Start] --> B{Is it working?}
    B -->> C

Shown under the editor:  Syntax error on line 3.

-->> is a sequence-diagram arrow; in a flowchart the arrow is -->. Fixing it redraws the diagram.

Privacy

Mermaid runs inside the browser and the PNG is drawn on a canvas in the page. The diagram code is not sent anywhere and nothing is stored.

Frequently asked questions

How do I export a Mermaid diagram as a PNG?
Paste the Mermaid code, choose a background and a scale of 1×, 2× or 3×, then select Download PNG. 2× gives a sharp image on high-density screens and in slides. Download SVG instead if the diagram needs to scale without blurring.
How do I find a syntax error in Mermaid code?
The editor shows "Syntax error on line N" under the code, with Mermaid's message and what it expected next. The line number counts every line in the editor, including front matter and comments, so it points at the line you see.
Can I export a Mermaid diagram with a transparent background?
Yes. Choose Transparent before downloading; both the PNG and the SVG are then left without a background. With the Dark theme, a transparent background suits a dark page, while White suits documents.
Is my Mermaid code uploaded to a server?
No. Mermaid is part of the page and draws the diagram in your browser, and the PNG is made on a canvas in the same page. Nothing is sent or stored.