Sometimes you need a diagram as a file — for slides, a Word document, a design tool or a platform that doesn't render Mermaid. MermaidViewer exports any diagram to PNG, SVG or PDF directly in your browser, so your code never leaves your device.
Which format should you choose?
| Format | Best for | Notes |
|---|---|---|
| SVG | Websites, docs, Figma, further editing | Vector — sharp at any size, small files, editable text |
| PNG | Slides, chat, email, Word | Choose 2x–4x scale for crisp results on high-DPI screens |
| Printing, reports, sharing with non-technical people | Vector PDF that keeps text selectable |
Exporting in the editor
- Open the editor and paste your code.
- Choose a theme (default, neutral, dark, forest or base) from the toolbar.
- Click Export and pick PNG, SVG or PDF. For PNG, choose the scale and whether the background is transparent or white.
- Use Copy PNG to paste the image directly into Slack, Google Docs or Notion.
Need a quick conversion without the full editor? Use the dedicated Mermaid to PNG, Mermaid to SVG and Mermaid to PDF converters.
Exporting from the command line
For automation (for example in CI), the official Mermaid CLI converts files in bulk:
bash
npx -p @mermaid-js/mermaid-cli mmdc -i diagram.mmd -o diagram.svg
npx -p @mermaid-js/mermaid-cli mmdc -i diagram.mmd -o diagram.png -s 3 -b transparentTroubleshooting exports
- Blurry PNG — increase the scale to 3x or 4x.
- Black background in dark mode — choose a white background or switch to a light theme before exporting.
- Fonts look different — SVGs use the viewer's fonts; export PNG or PDF for pixel-identical output.