Skip to content

Mermaid to image & SVG converter

Render Mermaid diagram syntax into sharp SVG vectors or high-DPI PNG and JPG images.

Starter templates Drop a .mmd or .md file below
Live preview Flowchart 606×1104 px
Rendered Mermaid diagram preview

How to use Mermaid to image

  1. Enter or load diagram syntax. Pick one of the six Starter templates, paste Mermaid code into the Mermaid syntax editor, or click Load .mmd or .md file.
  2. Customize theme and framing. Choose a Theme, pick White, Transparent, Dark, or Custom under Background, and set Padding (px) between 0 and 160.
  3. Export or copy your diagram. Pick PNG, SVG, JPG, or WebP under Format, select 1x, 2x, or 4x under Scale, and click Save diagram, Copy PNG, or Save SVG.

Everything runs in this browser tab. Nothing you paste or open is uploaded or logged, so it's safe for keys, tokens and private data.

Compiling Mermaid flowcharts and sequence diagrams with Dagre graph layout

Architecture diagrams often start as plain-text notes inside pull requests and design docs. Instead of sending proprietary system topologies to a hosted rendering API, this tool compiles Mermaid syntax directly in your browser tab using Dagre graph layout. Every node, arrow, subgraph, and label is positioned locally with live syntax validation.

Six diagram families and starter templates

The built-in parser recognizes six diagram families: flowchart (including graph in TD, LR, BT, and RL directions), sequenceDiagram, stateDiagram-v2, classDiagram, erDiagram, and pie. Clicking any button under Starter templates loads a complete working example so you can inspect valid syntax before editing.

For node shapes, subgraphs, and dashed or dotted edges, the compiler follows the conventions in the Mermaid Flowchart Syntax Documentation. When a line contains an invalid arrow or unrecognized header, Live preview displays the exact line number and expected syntax so you can fix it immediately.

How does batch extraction from Markdown files work?

Engineering specs frequently store three or four diagrams inside a single README.md or RFC document. Dropping a .mmd, .mermaid, .md, or .txt file via Load .mmd or .md file extracts every fenced mermaid code block automatically.

When multiple blocks are found, selector pills appear above Mermaid syntax so you can switch between diagrams, edit individual blocks without losing changes, or click Export all as ZIP to bundle every chart at once. If you want to turn the surrounding Markdown prose into a paginated document instead, you can export complete Markdown documents with headings and tables as PDFs.

How does pure SVG compilation prevent foreignObject text clipping?

Most browser Mermaid editors wrap node labels inside SVG <foreignObject> HTML blocks, which causes text clipping in Mermaid SVG exports and triggers tainted-canvas errors on PNG downloads. This compiler emits pure SVG <text> and <rect> primitives instead, so rasterization stays untainted and every label exports cleanly.

Zero foreignObject nodes and untainted canvas rasterization

Because the compiler uses @dagrejs/dagre in pure TypeScript without touching the page DOM, diagrams export reliably across Chrome, Firefox, and Safari. For chronological interactions, participant lifelines, alt branches, and autonumber steps follow the Mermaid Sequence Diagram Syntax Reference.

Before downloading, Live preview renders the generated vector string as an inline data:image/svg+xml image. If you plan to embed the raw vector file inside a web app or icon sheet and want smaller paths, pass the saved SVG through a browser-based svg optimizer.

Six color themes, 0–160 px padding, and background fills

Choose from six themes under Theme: Paper light, Ink dark, GitHub light, GitHub dark, Nord, and Blueprint / neutral. Switching to a dark theme automatically switches a White background to Dark so light edges stay visible.

Under Background, pick White, Transparent, Dark, or Custom with a color picker (#F8FAFC default). Padding (px) accepts any integer from 0 px to 160 px (with 24 px as the default) to control outer breathing room around the diagram edges.

Retina 1x–4x scaling, zoom controls, and clipboard PNG copy

Visual clarity depends on matching export resolution to where the diagram will live. High-DPI displays and slide decks blur 1x bitmaps, while oversized 4x exports bloat chat attachments. Separate preview zoom and export scale controls let you inspect fine text without changing output dimensions.

Choosing 1x, 2x, or 4x multipliers for docs and slides

When exporting raster formats (PNG, JPG, or WebP), Scale multiplies the SVG’s logical dimensions by 1x, 2x, or 4x. A diagram measuring 520 px by 340 px exports at 1,040 px by 680 px under 2x and 2,080 px by 1,360 px under 4x.

The rasterizer paints the self-contained SVG onto an HTML5 <canvas> via the MDN CanvasRenderingContext2D Web API Reference at the selected scale. Clicking Copy PNG places a PNG ClipboardItem directly onto your system clipboard for instant pasting into Slack, Linear, or Notion. For bespoke UI mockups or CSS grid layouts rather than node-edge charts, render custom HTML and CSS component cards when you need UI mockups.

Preview zoom vs exported pixel dimensions

Use the -, 100%, and + buttons above Live preview to zoom between 50% and 250% in 25% increments. Zoom only scales the on-screen preview inside the scrollable frame and never alters the downloaded image resolution, which is shown next to the diagram-type badge.

When should you export Mermaid diagrams as SVG vs PNG vs JPG?

Export SVG whenever diagrams will live on documentation sites, wikis, or print layouts where infinite zoom sharpness matters. Choose PNG at 2x or 4x scale for chat apps, slide decks, and platforms that block SVG uploads, and reserve JPG or WebP for compact email attachments.

Vector output conforms to the W3C Scalable Vector Graphics (SVG) 2 Specification, keeping file sizes tiny while preserving crisp edges at any magnification. The table below summarizes each export format’s behavior in this tool.

Format Transparency Scale control Best destination Key trade-off
SVG Supported Vector (infinite) Docs sites, GitHub, Figma Blocked by some chat/email apps
PNG Supported 1x, 2x, 4x Slack, Notion, Google Slides Larger bytes at 4x scale
WebP Supported 1x, 2x, 4x Blogs, web guides, portals Older desktop apps may lack support
JPG White fill only 1x, 2x, 4x Email, legacy CMS uploads Lossy edges around thin text
ZIP batch Matches Format 1x, 2x, 4x Multi-diagram READMEs Bundles all extracted blocks

Tip: Click Save SVG below Save diagram to download a vector file in one click, or convert an existing vector later with SVG to PNG if a colleague asks for a high-DPI raster copy.

Questions

Which Mermaid diagram types are supported?

The compiler renders flowcharts (graph and flowchart in TD, LR, BT, or RL directions with subgraphs), sequence diagrams, state diagrams (stateDiagram-v2), class diagrams, entity-relationship (ER) diagrams, and pie charts. Six matching Starter templates let you load working examples for each family.

Can I drop a Markdown file with multiple Mermaid code blocks?

Yes. Dropping a .md or .markdown file scans for every fenced mermaid block and displays selector buttons above the editor. You can switch between blocks, edit any diagram in place, or click Export all as ZIP to download every diagram in one archive.

Why does a transparent background switch to white when I select JPG?

JPEG compression does not support an alpha transparency channel. Whenever JPG is selected under Format, the Transparent option is hidden and automatically falls back to a solid white (#FFFFFF) canvas fill so arrows and labels remain legible.

What is the difference between Preview zoom and Scale?

Preview zoom (50% to 250%) only magnifies or shrinks the live preview inside your browser tab so you can inspect dense labels. Scale (1x, 2x, or 4x) multiplies the exported pixel dimensions when saving PNG, JPG, or WebP files.

Why do exported Mermaid SVG files open cleanly in Figma and Illustrator?

Many editors embed HTML inside SVG foreignObject tags, which vector design apps cannot parse and browsers block from canvas exports. This compiler emits pure SVG text and vector shapes, so files open cleanly in Figma and Illustrator and copy via ClipboardItem.

How do I export a single diagram quickly as SVG?

Click Save SVG below the Save diagram button at any time to download a standalone .svg vector file immediately. You can also choose SVG under Format and click Save diagram to see file size stats on the result screen.

Updated