Mermaid to PNG and SVG converter

Write Mermaid code, watch the diagram draw, and save it as a PNG or SVG image.

Converter

BackgroundPNG size
flowchart.svg

Jotura, a free notes app, draws Mermaid diagrams inside your Markdown notes as you write them. Download Jotura

How to turn Mermaid code into an image

  1. Add the code. Paste it, type it, or choose an example from the menu above the box.
  2. Set the look. Pick a theme and a background. The preview shows the image as it will be saved.
  3. Download. Choose the PNG size, then save a .png or a .svg.

PNG or SVG

FormatUse it for
PNGDocuments, slides, chat and email, anywhere that takes a picture
SVGWeb pages, design tools and print, where the image has to stay sharp at any size

Mermaid to PNG questions

How do I convert Mermaid to PNG or SVG?

Paste your Mermaid code into the box, or pick an example to start from. The diagram draws as you type. Choose a theme and background, then click Download .png or Download .svg. Copy SVG puts the SVG code on the clipboard to paste into a web page or a design tool.

Can I convert Mermaid on the command line?

The official mermaid-cli does it with one command. It downloads a headless browser the first time, so the first run takes a while. Change the extension of the output file to .svg or .pdf for those formats, and add -b transparent for a transparent background.

npx -p @mermaid-js/mermaid-cli mmdc -i diagram.mmd -o diagram.png

How do I get a transparent background?

Set Background to None. The preview shows a checkerboard where the image will be see-through. PNG and SVG both keep the transparency. Pick Colour to match a slide or a page instead.

How do I make a high resolution PNG?

Set PNG size to 3x or 4x. A diagram that is 600 pixels wide at 1x comes out 2400 pixels wide at 4x, which stays sharp on a large screen and in print. For the sharpest result in any size, use the SVG, which is a vector image.

Which diagram types work?

Every diagram type in Mermaid 11, including flowcharts, sequence, class, state, entity relationship, Gantt, pie, mind map, timeline, journey, quadrant and Git graphs. The examples menu has a starting point for the common ones.

Why does my diagram show an error?

Mermaid could not read part of the code, and the message names the line where it stopped. Common causes are a missing bracket, a label with special characters that needs quotes, like A["Step (1)"], or a first line without the diagram type. The last diagram that worked stays on screen while you fix it.

Is my diagram uploaded?

No. Mermaid runs in your browser and the images are made on your device, so your code never leaves it.

How do I put the diagram in Word, Google Docs or slides?

Download the PNG at 2x or more and insert it as a picture: Insert > Pictures in Word and PowerPoint, Insert > Image > Upload from computer in Google Docs and Slides. Recent versions of Word and PowerPoint also take the SVG, which stays sharp when you resize it.

The Markdown viewer draws Mermaid diagrams inside a whole Markdown document, and the Markdown to HTML converter turns Markdown into a web page.