Mermaid to Image

Paste the Mermaid code and the diagram is drawn in your browser. A PNG is the diagram size times the scale: an 800 × 600 px diagram saved at 2x is a 1,600 × 1,200 px image. A ```mermaid fence around the code is removed automatically.

Paste Mermaid code to see the diagram

Did this solve your problem?
Prefer us on Google

How to use

  1. Paste the Mermaid code. A ```mermaid fence before and after the code is removed for you. Nothing leaves your browser.
  2. Pick a theme: default, dark or neutral. The diagram updates as you type.
  3. Choose a scale (1x, 2x or 3x) and a transparent or white background, then download the PNG, or download the SVG for a sharp vector file.
  4. If the code has a syntax error, the line number and the message appear instead of the diagram. Fix that line and the diagram comes back.

How it works

The diagram is drawn by the Mermaid library (version 12) in your browser, with its security level set to strict. Click handlers and scripts inside the code are not run, and text labels are drawn as plain SVG text instead of HTML.

The size of the PNG is the size of the SVG diagram in pixels times the scale. An 800 × 600 px diagram at 2x gives 1,600 × 1,200 px, and at 3x gives 2,400 × 1,800 px. Images larger than 16,384 px on a side, or about 120 million pixels in all, are refused because browsers cannot make such a canvas.

To make the PNG, the SVG is loaded as an image and copied onto a canvas. A white background is painted first when you choose white; with a transparent background the PNG keeps an alpha channel. The SVG download is the same drawing as a vector file with a fixed width and height.

The dark theme draws light text, so it is easy to read on a dark page but hard to read on a white background. Use it with a transparent background on dark slides, or choose default or neutral for white paper.

A line number in an error refers to the text box above. When a ```mermaid fence was removed, the count still starts at the first line you pasted.

FAQ

Why does ChatGPT show Mermaid code instead of a picture?

Chat apps often print a diagram as text in a code block. Paste that text here and it is drawn as an image you can save.

Is my diagram uploaded?

No. The code is drawn in your browser and nothing is sent to a server. The Mermaid library is downloaded only when you start typing.

Which diagrams work?

Flowcharts, sequence, class, state, ER, Gantt, pie, mindmap, timeline and the other types that Mermaid 12 supports. The first line of the code, such as flowchart TD or sequenceDiagram, tells Mermaid which type it is.

The PNG looks blurry. What can I do?

Use 3x, or download the SVG, which stays sharp at any size. Most editors and slide tools can import SVG.

Why is the dark theme unreadable on a white background?

It draws light text for dark pages. Switch to a transparent background on a dark surface, or use the default or neutral theme.

Why can't I click links inside the diagram?

The strict security level turns off click events and scripts, so a diagram pasted from someone else cannot run code in your browser.