October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
Developer Tools

How to Export Mermaid Diagrams as PNG (Browser, Mermaid Chart, and CLI)

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The fastest way to export a Mermaid diagram as a PNG is to open it in Mermaid Live Editor, wait for the preview to render, then choose Actions → export PNG. For repeatable builds, use Mermaid CLI (mmdc); for a no-install workflow, Mermaid Chart also exports PNG with transparent or custom-color backgrounds. Keep the original Mermaid source beside the image so you can edit and regenerate it later.

Choose the export method that fits your work

Method Best for Setup PNG controls Repeatability
Mermaid Live Editor A one-off diagram or quick share Browser; paste Mermaid code Simple PNG export from Actions Manual
Mermaid Chart Hosted editing and presentation graphics Browser; no local Node install Default, transparent, or custom hex background Manual, with hosted source
Mermaid CLI (mmdc) Documentation builds, CI, and batch conversion Node.js package, local install, or Docker Theme, background, and output size options Scriptable and repeatable

PNG is convenient for slides, documents, issue trackers, and ordinary sharing. It is a raster image, so very large diagrams can look soft when enlarged. Use SVG when the destination is print, a large poster, or a responsive web page; SVG scales without losing sharpness.

Export a Mermaid diagram from Mermaid Live Editor

  1. Open Mermaid Live Editor and paste your definition into the code pane, or open an existing Mermaid example.
  2. Wait for the preview pane to finish rendering. Fix any syntax or parse error before exporting.
  3. Open the Actions section.
  4. Choose export PNG and save the resulting file.
  5. Save the Mermaid definition (or the Markdown file containing it) next to the PNG. The image is a snapshot; the source is what lets you change labels, layout, and styling later.

The same Actions area can save SVG or Markdown. If you expect to reuse the diagram at different sizes, save SVG as well as PNG.

When the preview will not export

An export button cannot repair invalid Mermaid syntax. Resolve the parse error shown in the editor first, then wait for a complete preview render. For a diagram with remote assets or extensive styling, allow the preview to settle before opening Actions.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Export PNG in Mermaid Chart

  1. Open the diagram in Mermaid Chart and select Export.
  2. Choose PNG as the output format.
  3. In the PNG options, select the default theme background, transparent, or a custom hexadecimal color.
  4. Export and check the saved image against the destination document or slide.

PNG is intended for presentations, documents, reports, and general sharing. Mermaid Chart also offers SVG, PDF, and MMD exports, so you can preserve both a shareable image and an editable source.

Make theme styling survive export

Editor preference settings are not guaranteed to carry into an export. When a theme matters, put the theme configuration in the diagram’s front matter rather than relying only on editor preferences. This makes the intended styling part of the source and easier to reproduce.

Export Mermaid to PNG with the CLI

Mermaid CLI is the practical choice when you need the same diagram generated repeatedly on a developer machine or in a build pipeline. It takes a Mermaid definition file and generates SVG, PNG, or PDF.

Install Mermaid CLI

Install the official package globally with npm:

npm install -g @mermaid-js/mermaid-cli

You can also install it locally in a project or run it through Docker. A local project install is often preferable when a team wants the package version recorded in its dependency files.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Render a file

Create input.mmd containing your Mermaid definition, then run:

mmdc -i input.mmd -o output.png

The command reads the definition and writes output.png. Use an explicit output path in scripts so generated files land in a predictable directory.

Transparent background, dark theme, and larger output

These documented variants cover common presentation needs:

mmdc -i input.mmd -o output.png -t dark -b transparent
mmdc --input input.mmd --output output.png --size 4000
  • -t dark applies the dark theme.
  • -b transparent removes the solid background so the PNG can sit on a colored page or slide.
  • --size 4000 requests a larger render when the default image is too small for its destination.

The CLI also accepts Mermaid text from standard input, which is useful when another command generates the source:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
cat input.mmd | mmdc -i - -o output.png

Keep the exact CLI command, package version, and source file under version control if the image is part of published documentation. That gives you a reproducible regeneration path instead of an unexplained binary artifact.

Improve PNG quality and readability

Prevent clipping

Check the rightmost and bottommost nodes after export. Clipped labels usually indicate that the render is too small or that the diagram is being viewed at an unsuitable scale. Increase the CLI size where appropriate, or export SVG when the destination can display vector artwork.

Choose a background deliberately

Use transparent PNG when the image must blend into a slide, webpage, or colored document. Use a custom hex background when the surrounding design requires a known color. A default theme background is safer for a standalone image that will be shared independently.

Use a theme that is part of the source

Put important theme configuration in Mermaid front matter. Relying only on a browser editor preference can produce an export that looks different from the preview or from a colleague’s machine.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Know when PNG is the wrong format

  • Slides and ordinary documents: PNG is straightforward and widely supported.
  • Print or very large diagrams: SVG is usually sharper because it is vector-based.
  • Web embedding: SVG is often preferable when responsive scaling is required.
  • Archival or editing: retain the MMD or Markdown source in addition to any rendered format.

Automate exports in a project

A simple project layout keeps editable source and generated assets together:

diagrams/
  architecture.mmd
  architecture.png
  architecture.svg

For a one-command refresh, add a script that calls mmdc with fixed input and output paths. In continuous integration, install the pinned local CLI dependency (or use the same Docker image each time), render all .mmd files, and fail the job when a definition has a parse error. This catches broken diagrams before documentation is published.

For many diagrams, generate outputs into a separate build directory rather than overwriting source files. Review the generated PNGs when changing Mermaid or the CLI version: layout algorithms, fonts, and theme defaults can alter line wrapping or spacing even when the source is unchanged.

Or skip the browser setup

If your Mermaid diagram is already rendered on a URL—such as a documentation page, dashboard, or internal preview—you can capture that page with ScreenshotNeo instead of configuring a browser automation script. Its API accepts a URL and returns PNG, JPEG, WebP, or PDF. Cookie and consent banners, newsletter popups, and chat widgets are removed before the shot; bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a direct PNG capture, see the ScreenshotNeo API documentation and run:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

The example URL is replaceable with the URL that displays your Mermaid diagram. The same request in Python is:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

And in Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));

ScreenshotNeo includes 63 options for cases such as full-page capture with lazy images loaded, CSS-selector element capture, dark mode, device and retina settings, custom CSS or JavaScript, waits, request blocking, headers and cookies, timezone and geolocation, resizing, chosen cache TTLs, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, and a usage API. Every feature is on every plan: 1,000 shots per month are free with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting Mermaid PNG exports

“Parse error” or an empty preview

Fix the Mermaid syntax indicated by the editor or CLI output. Confirm that the file passed to -i is the intended file and that it is saved before running mmdc.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The PNG has a solid background instead of transparency

In Mermaid Chart, choose the transparent PNG option. With CLI, add -b transparent. If a downstream editor displays a checkerboard, that is its transparency indicator, not necessarily a defect.

The theme or colors changed

Move theme configuration into Mermaid front matter. Do not depend solely on an editor preference, because that preference may not be embedded in the exported artifact.

Text is tiny or cut off

Increase the export scale or CLI size, reduce unnecessary diagram width, and check the image at its final display size. Switch to SVG when the destination needs substantial enlargement.

The command “mmdc” is not found

Install @mermaid-js/mermaid-cli globally as shown above, or invoke the locally installed binary through your project’s package runner. Verify that the Node.js and npm installation used by your shell is the same one where the package was installed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fonts or layout differ between machines

Rendering depends on the environment’s available fonts and package version. Pin the CLI version, use a consistent local or Docker environment, and review regenerated images after upgrades.

FAQ

Can I export Mermaid code directly as a PNG?

Yes. Render the definition in Mermaid Live Editor or Mermaid Chart, or pass an .mmd file to Mermaid CLI with mmdc -i input.mmd -o output.png.

How do I get a transparent Mermaid PNG?

Choose transparent in Mermaid Chart’s PNG options, or use Mermaid CLI’s -b transparent option.

Should I keep the Mermaid source after exporting?

Yes. Keep the .mmd or Markdown source with the image so labels, themes, and layout remain editable.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why does my PNG look pixelated?

PNG is raster. Increase the export scale or CLI size, or use SVG when the image must scale substantially.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.