Browser-based developer tool · text in, diagram out

Mermaid Diagram Editor

Write Mermaid text and watch the flowchart, sequence, class, state, ER, Gantt, pie, mind map or timeline redraw as you type. Pick a theme, save the result as SVG or a PNG up to 4x, copy the SVG, or share the diagram as a link that holds the text inside the URL itself. Rendering is done by the Mermaid library in your browser tab, in strict security mode.

277 characters, 10 lines

The diagram is not ready to export yet.

Preparing the diagram...

The Mermaid library downloads from this site as a separate script on first use and is cached after that; your text is never uploaded.

Mermaid Diagram Editor

Operator: Abdulla Al Fahad. How tools are built and checked

Mermaid lets you describe a diagram in a few lines of text and have software draw it, which means the diagram can live in a README, a ticket or a pull request and be edited like code. This editor puts the text box and the drawing side by side. Type, pause for a moment, and the picture updates; make a mistake, and a one-line message points at the line that Mermaid could not read.

From there you can save the drawing as an SVG or as a PNG at one to four times its natural size, copy the SVG markup to paste into another tool, or copy a link that carries the diagram inside the URL. The drawing is done by the open-source Mermaid library running in your browser tab, set to its strict security mode, so the text you type is not sent anywhere.

Key features

  • Live preview with a 400 ms pause after typing, using Mermaid's parser first so that a bad line produces a readable error instead of a broken picture
  • Error messages reduced to the line number, the text Mermaid stopped at and the source line, with a button that selects that line in the text box
  • Nine templates, five themes, and a character and line counter
  • Save SVG, Save PNG at 1x to 4x, Copy SVG, and Save text as .mmd
  • Share link that stores the text (and theme) in the part of the URL after the #, compressed with deflate when the browser supports it
  • Opening a shared link restores the text and theme before the first drawing

Supported diagram types, themes and export limits

The editor accepts whatever the bundled Mermaid release (version 12) understands. Nine starting templates cover the common types: flowchart, sequence diagram, class diagram, state diagram, entity-relationship diagram, Gantt chart, pie chart, mind map and timeline. Each one is a complete, valid diagram rather than a stub, so changing a label or adding a line is the quickest way to learn the syntax of that type.

Five themes are offered: default, neutral, dark, forest and base. They are Mermaid's own built-in themes. Per-diagram directives and front matter in the text, such as an init block that sets themeVariables, still apply on top of the chosen theme. Mermaid runs with securityLevel set to strict, which encodes HTML in labels and disables click handlers and links that run script, so a diagram pasted from an unknown source cannot run code in the page.

Only the first 60,000 characters of the text are drawn, and a longer text is reported as cut off. Drawing happens 400 milliseconds after you stop typing, one render at a time. If the text does not parse, the preview keeps the last version that did, dimmed, with the error shown under the text box.

SVG export is rendered a second time with HTML labels switched off, so every label is plain SVG text instead of an HTML box inside a foreignObject element. That is what lets the same drawing be rasterised onto a canvas for PNG without the browser refusing to read the pixels back, and it also makes the SVG open correctly in vector editors that do not support foreignObject. The trade-off is that long labels are not word-wrapped the way the on-screen preview wraps them, so a very wordy node may look wider in the file than in the preview.

PNG width and height are the SVG's own size multiplied by the scale you choose, from 1x to 4x. If the result would pass about 16 million pixels or 16,000 pixels on a side, the scale is lowered and the scale actually used is shown; this keeps phones and Safari, which have smaller canvas limits than desktop Chrome, from failing silently. The background can match the theme (white, or dark slate for the dark theme), be forced white, or be transparent.

How it works

The Mermaid library is not part of the page's first download. The first time the page needs to draw, it fetches Mermaid as a separate script from this site, and the browser caches it for later visits. Before each draw the page calls Mermaid's parse function on the text; if that throws, the error is shortened and shown, and nothing is drawn. If parsing passes, the text is rendered into an SVG string, which is inserted into the preview.

For an export, the SVG string is read back with a DOM parser. Mermaid writes width="100%" and a max-width style on the root element, so the page replaces them with the pixel size from the viewBox. For a background other than transparent it inserts a filled rectangle as the first child, so the colour survives in any viewer. The PNG is made by loading that SVG as an image from a data URL, drawing it onto a canvas of the scaled size, and reading the canvas back as a PNG.

A share link is built from the text. When the browser provides CompressionStream, the UTF-8 bytes are compressed with deflate-raw and encoded as URL-safe base64 under the key c; without it, the bytes are only base64url-encoded under the key t. The theme goes in as th. Everything sits after the #, a part of the URL that browsers keep to themselves and never put in a request. Opening such a link decodes the hash with the matching decompression, and a hash that cannot be decoded produces a message and leaves the starter flowchart in place.

Common use cases

  • Sketching a release process or an onboarding flow during a meeting and saving the result as a PNG for the notes
  • Working out a sequence diagram for an API call before writing the documentation, then pasting the text into a README that renders Mermaid
  • Checking why a Mermaid block that works in one tool fails in another, using the line-specific error
  • Producing a Gantt chart or timeline for a slide, as an SVG that stays sharp when scaled
  • Passing a diagram to a colleague as a link instead of a screenshot, so they can change it

How to use this tool

  1. Pick a template from the list, or clear the box and write your own Mermaid text starting with a type keyword such as flowchart TD.
  2. Edit the text. The preview redraws about half a second after you stop typing.
  3. If a red message appears, read the line number and press Select line to jump to it in the text box.
  4. Choose a theme, a PNG scale and a background.
  5. Press Save SVG or Save PNG, or Copy SVG to paste the markup into another editor.
  6. Press Copy share link to put a link to the diagram on the clipboard and in the address bar.

Example

A four-line flowchart typed into the text box

flowchart LR
  A[Draft] --> B{Review}
  B -->|approved| C[Publish]
  B -->|changes| A

What the page produces

Preview: three nodes laid out left to right, a rectangle (Draft), a diamond (Review) and a rectangle (Publish), with a loop arrow from Review back to Draft labelled changes.
Save PNG at 2x: the SVG's natural size multiplied by two, on a white background when the theme is default.
Share link: the same four lines, compressed and encoded after the # of the page address, so the link does not contain the words "Draft" or "Review" in readable form.

Tips for best results

  • Start from the template closest to what you need. The state, ER and Gantt syntaxes have small traps, such as dateFormat and axisFormat in Gantt, and the templates already get them right.
  • Quote labels that contain brackets, parentheses or punctuation: A["Total (net)"] works where A[Total (net)] does not.
  • Use the dark theme only with the Match theme background; on a white page its light text can be hard to read.
  • For slides, save SVG and insert it as a picture so it stays crisp; use a 3x or 4x PNG when the destination does not take SVG.
  • Before sharing a link in chat, check the length message. Links past about 8,000 characters are still created, but some apps shorten or break them, and the page refuses to create one past 100,000 characters.

Common pitfalls

The page does not store your text. Reloading without a share link returns to the starter flowchart, so copy the text or save the .mmd file first.

Share links contain the diagram, so anyone who has the link can read it. Do not put secrets in a diagram you plan to send as a link.

Some diagram types in newer Mermaid releases are marked experimental, and the bundled version may not know a keyword that a newer site documents. The error will say that the diagram type was not recognised.

Text rendered by other tools can differ slightly: GitHub, GitLab and Notion each bundle their own Mermaid version and may accept or reject different syntax from the version here.

If a PNG fails with a message about HTML text boxes, the browser refused to read the drawing back from the canvas. Save the SVG instead and convert it in a vector editor.

What the error messages mean

Mermaid's parser reports the position where the text stopped making sense, which is often the line after the real mistake. A message such as Line 3: unexpected "-->" usually means an arrow follows another arrow or a node has no name, and the actual slip is on that line or the one above it. The page shows the offending source line so you can compare it with the syntax of the diagram type.

A message saying Mermaid could not tell which kind of diagram this is means the first line does not start with a known keyword. It is the usual result of pasting a Markdown code fence, so remove the three backticks and the word mermaid around the text.

Some failures come from the drawing step rather than the parser, such as an invalid date in a Gantt chart. Those messages carry no line number, and the page shows the first line of what Mermaid reports.

Where the text goes

Drawing, exporting and link creation all happen in the open tab. The only network request the page makes is for its own scripts, including the Mermaid chunk the first time it is needed.

A share link is different from an upload: nothing is stored on a server, so there is no list of shared diagrams and nothing to delete. The text exists only in the link itself and in whatever place you paste it.

Frequently asked questions

Why does the preview not match the exported SVG exactly?

The export is drawn with plain SVG text so it can be rasterised and opened in vector editors, while the preview uses HTML labels that wrap long text. Spacing around long labels can differ slightly between the two.

How long can a share link be?

The page creates links up to 100,000 characters and warns above 8,000. Compression typically shrinks plain diagram text a good deal, but a very large diagram still makes a very long link; save it as a .mmd file instead.

Which Mermaid version is this?

The page bundles Mermaid 12. Syntax added in later releases will not parse here, and syntax removed in 12 will not either.

Can I click links and callbacks in a diagram?

No. Strict security mode turns off click handlers that run script, so diagrams from other sources cannot execute code. Plain links inside exported SVG files are a matter for the viewer you open them in.