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.