To turn a Mermaid diagram into an image, export PNG or SVG from Mermaid Live Editor or the mmdc CLI.
mmdc command, which turns a .mmd or Markdown file into SVG, PNG, or PDF. When you need an editable, journal-ready version instead, SciFig FlowChart (flowcharts and diagrams) has AI redraw the diagram from your description, with every box, label and arrow editable, and exports SVG, PNG or PPTX.Mermaid renders diagrams from text, which makes it excellent for documentation that lives in version control. Getting a file out of it — one you can drop into a manuscript, a slide, or a poster — is a separate step that trips people up, mostly because the default export is a PNG at screen resolution.
| Goal | Method | Formats | Install needed | Code leaves your machine? |
|---|---|---|---|---|
| One diagram, right now | Mermaid Live Editor → Actions → PNG or SVG | PNG, SVG | No | Yes, pasted into a hosted web page |
| Repeatable or batch export | mermaid-cli (mmdc) | SVG, PNG, PDF | Node.js, or run once with npx | No, renders locally |
| Preview while writing Markdown | VS Code extension or Obsidian | Preview; some extensions export SVG/PNG | Editor extension | No |
| Always-current docs | mmdc as a CI build step | SVG, PNG, PDF | In the pipeline | Stays in your CI |
| Editable, journal-ready redraw | SciFig FlowChart: describe the diagram, or attach the Mermaid text as a .md file, and AI redraws it with every box, label and arrow editable | SVG, PNG, JPG, PPTX | No, runs in the browser | Yes, uploaded to SciFig |
The last row is a different kind of tool: instead of rendering your Mermaid code, AI redraws the diagram from your description as native SVG, so every node, label and arrow comes out as an element you can move, restyle and lay out to a journal's conventions. It is free to start, no card required, with 150 credits on your first day, and editing and SVG/PNG/PPTX export are free.

The Command Line Route
@mermaid-js/mermaid-cli, which exposes an mmdc command:npm install -g @mermaid-js/mermaid-cli
mmdc -i diagram.mmd -o diagram.svg # vector, preferred
mmdc -i diagram.mmd -o diagram.pdf # vector PDF
mmdc -i diagram.mmd -o diagram.png -s 3 # raster at 3x scale| Format | Vector | Good for | Avoid when |
|---|---|---|---|
| SVG | Yes | Web, further editing, most journals | Target requires EPS |
| Yes | Manuscripts, print, slides | You need to edit in a browser tool | |
| PNG | No | Chat, wikis, quick previews | Print or any scaling |
mmdc also reads Markdown. mmdc -i notes.md -o notes-rendered.md renders every mermaid code block in the file to an image and writes a copy of the Markdown that points at those images — handy for a README or a lab notebook full of diagrams.See AI Scientific Figure Generation in Action
Watch how researchers create publication-ready scientific figures from text descriptions.
Explore the ToolHow to export Mermaid to PNG (and fix blurry, tiny or cropped output)
mmdc an output name ending in .png. The PNG is trimmed to the diagram itself, and its size comes from two settings: the page width the diagram is laid out in, and the scale factor. Most "bad PNG" complaints trace back to one of the fixes below.-s multiplies the pixel density without changing the layout. -s 2 suits slides, -s 3 or -s 4 suits print.mmdc -i diagram.mmd -o diagram.png -s 3-w sets the page width (default 800 px) and -H the page height (default 600 px). Mermaid shrinks a wide diagram to fit the page, so a long left-to-right flowchart can come out with unreadable labels. A wider page keeps the labels at full size.mmdc -i diagram.mmd -o diagram.png -w 1600 -s 2graph TD instead of graph LR).-b sets the background for PNG and SVG (not PDF). The default is white.mmdc -i diagram.mmd -o diagram.png -b transparent -s 3-c loads a JSON configuration for Mermaid, so every diagram you export shares one font and theme. -t picks a built-in theme (default, forest, dark, neutral) for a single run.{
"theme": "neutral",
"themeVariables": { "fontFamily": "Arial" }
}mmdc -i diagram.mmd -o diagram.png -c config.json -s 3mmdc. If the export looks different from your preview, write the theme into the diagram.mmdc will not install: run it with npx. Global installs fail on locked-down machines. npx downloads the CLI into a cache and runs it once, with no global install. The first run also downloads a headless browser, so it takes a few minutes.npx -y @mermaid-js/mermaid-cli -i diagram.mmd -o diagram.png -s 3Timeline and Sequence Diagram Examples
.mmd file.timeline
title Research project timeline
2024 : Grant awarded
2025 : Pilot study : Data collection
2026 : Analysis : Manuscript submitted
mmdc -i timeline.mmd -o timeline.png -s 3sequenceDiagram
participant R as Researcher
participant S as Sequencing core
participant P as Analysis pipeline
R->>S: Submit samples
S-->>R: Raw reads
R->>P: Run QC and alignment
P-->>R: Results table
mmdc -i sequence.mmd -o sequence.svgOther Export Routes
mmdc is a CLI, diagram rendering can be a build step. A common pattern is committing .mmd sources and generating images during documentation builds, so the rendered output never goes stale relative to the source.- run: npm install -g @mermaid-js/mermaid-cli
- run: mmdc -i docs/architecture.mmd -o docs/architecture.svg
Exporting from Obsidian, VS Code and Into Papers or Slides
mermaid code blocks in the note preview, but it has no built-in button to save a single diagram as an image file. Exporting the note to PDF carries the diagram along. For a standalone PNG or SVG, copy the code block into Mermaid Live Editor, or save it as a .mmd file and run mmdc. Because mmdc reads Markdown, you can also point it at the note itself..mmd file next to your Markdown and render it with mmdc from the integrated terminal.-s 3 or higher only when a submission system rejects vector files.
Controlling Appearance
Mermaid's defaults are built for documentation, not for publication. Three levers matter:
- Themes.
%%{init: {'theme':'neutral'}}%%at the top of the file.neutralandbaseprint better than the default. - Fonts. Set
fontFamilyin the init block so the diagram matches the surrounding document. - Direction.
graph LRversusgraph TDchanges the aspect ratio, which matters more than it sounds when fitting a diagram into a column.
A research process flowchart with a neutral theme and a print font:
%%{init: {'theme':'neutral', 'themeVariables': {'fontFamily':'Helvetica'}}}%%
graph LR
A[Sample collection] --> B[Extraction]
B --> C[Sequencing]
C --> D[Analysis]
When Mermaid Is the Wrong Tool
Mermaid computes layout automatically, and you get limited control over it. That is a feature for documentation and a limitation for scientific figures where composition carries meaning.
| Mermaid fits | Switch to SciFig FlowChart or a vector editor |
|---|---|
| Documentation that lives in version control | A manuscript figure that must match a journal's visual conventions |
| Diagrams regenerated on every build | Precise spatial arrangement you control box by box |
| Automatic layout is good enough | Positions that reflect real relationships, such as anatomical position or temporal sequence |
| Text-only source that diffs in review | Co-authors who edit the figure visually rather than in code |
A workable compromise: generate the structure in Mermaid, export SVG, then finish in a vector editor — accepting that the finishing step breaks regeneration.

.md file, and the text to diagram generator has AI draw an editable version as native SVG, where every box, label and arrow can be moved and restyled directly. For an interaction like the sequence example above, the sequence diagram generator does the same for participants and messages. It is free to start with 150 credits on your first day, and editing, saving and exporting SVG, PNG or PPTX are free. If you are weighing template-based design tools for the same job, see our Canva alternatives for diagrams.Tip
.mmd source alongside the exported image. The source diffs meaningfully in review and regenerates when things change; the image is what people actually look at. Keeping only one of the two costs you either reviewability or convenience.Create Scientific Figures Now
Describe your scientific figure in natural language — get publication-ready illustrations in minutes.
Try FreeRelated Reading
Related reading: Visualize Research with AI Text-to-Figure, 10 Best Scientific Illustration Tools in 2026, 7 Free Canva Alternatives for Scientific Diagrams (2026).



