merman-cli
merman-cli is a browserless Mermaid command-line renderer for SVG, PNG, JPG, PDF, and
ASCII/Unicode text output. The top-level command follows common mmdc workflows, while developer
subcommands expose merman's parse, layout, and render internals.
Install
The default binary includes SVG/PNG/JPG/PDF export, ASCII/Unicode text output, and RaTeX math rendering.
From a local checkout:
Quick Start
Top-level usage renders like mmdc:
- reads from stdin or writes to stdout:
|
|
When -o is omitted, top-level mode writes <input>.svg for file input and out.svg for stdin.
The output format is inferred from the output extension unless -e, --outputFormat, --format is
provided.
Output Formats
| Format | Top-level extension | Status |
|---|---|---|
| SVG | .svg |
Default, browserless renderer |
| PNG | .png |
Rust raster output |
.pdf |
Rust PDF output through SVG conversion | |
| JPG/JPEG | .jpg, .jpeg |
Rust extension beyond upstream mmdc |
| ASCII | .txt, .ascii |
Rust extension, enabled by default |
| Unicode | .txt, .ascii |
Rust extension, enabled by default |
Examples:
Markdown Input
.md and .markdown input files activate Markdown mode. Mermaid code blocks are extracted,
rendered as numbered artefacts, and optionally rewritten back into Markdown image links.
The command above writes README-1.svg, README-2.svg, and so on. The template output file itself
is not written unless the output path is Markdown.
The command above writes numbered SVG artefacts and rewrites Mermaid fences in
README.rendered.md to Markdown image links.
Use --artefacts or the Rust-friendly --artifacts alias to place images in a separate directory:
Use --jobs to bound parallel chart rendering. Results are still linked in source order:
Markdown mode does not support stdout output because it may need to write multiple artefact files.
Icon Packs
Iconify packs are loaded into a Rust SVG icon registry, so flowchart and architecture icon nodes can embed real icon SVGs without a browser.
Load an Iconify package name:
merman-cli first looks for node_modules/@iconify-json/logos/icons.json from the current working
directory upward. If no local package is found, it fetches
https://unpkg.com/@iconify-json/logos/icons.json.
Load an explicit prefix and source:
The prefix before # overrides the JSON prefix, matching the useful part of upstream loader
registration while keeping rendering browserless.
Rust Extensions
ASCII/Unicode
ASCII/Unicode output is enabled in the default CLI binary:
|
|
| \
Terminal text rendering currently supports flowchart/graph, sequenceDiagram, classDiagram, erDiagram, and xychart. Other diagram families still render to SVG/raster formats but return an unsupported-diagram error for ASCII/Unicode until a typed text renderer is added.
ClassDiagram and erDiagram text output include class/entity boxes, layered relationship layouts, same-endpoint lanes, simple spanning side lanes, and unrelated standalone components. Cyclic or denser relationship graphs return explicit diagnostics instead of silently dropping edges.
RaTeX Math
RaTeX math rendering is enabled by default:
|
Use --no-default-features only when you intentionally want to exclude default binary capabilities
such as RaTeX and ASCII/Unicode. In that build, --math-renderer ratex remains unavailable unless
the ratex-math feature is enabled explicitly, and ASCII/Unicode output remains unavailable unless
the ascii feature is enabled explicitly.
Developer Subcommands
Top-level mode is for mmdc-style export workflows. Developer subcommands remain available for
tooling, tests, and debugging:
render writes SVG to stdout by default. Use --out for files, --format ascii|unicode for
terminal text, and --format png|jpg|pdf for raster or PDF export.
Common Options
-t, --theme <theme>sets the Mermaid theme.-w, --width <width>and-H, --height <height>configure viewport-sensitive layouts.-b, --backgroundColor <color>sets SVG/raster background color.-c, --configFile <file>loads Mermaid JSON configuration.-C, --cssFile <file>injects CSS into SVG output before export.-I, --svgId <id>sets the root SVG id and marker id prefix.-s, --scale <n>controls PNG/JPG raster scale.--raster-fit-width <px>and--raster-fit-height <px>fit PNG/JPG output to a browser-like preview box before applying--scale.--raster-max-width <px>,--raster-max-height <px>, and--raster-max-pixels <n>set the PNG/JPG pixmap budget. Defaults are8192 x 8192and8192*8192total pixels.--raster-unboundeddisables the PNG/JPG pixmap budget for trusted oversized exports.-f, --pdfFituses a chart-sized PDF page instead of the top-level default Letter-sized page.-q, --quietsuppresses non-error logs.--text-measurer deterministic|vendoredcontrols text measurement.--math-renderer none|ratexcontrols math label rendering.--suppress-errorsemits an error diagram instead of failing on parse errors.--hand-drawn-seed <n>stabilizes rough/hand-drawn rendering where supported.
SVG Input Rasterization
merman-cli render --format png|jpg|pdf can rasterize existing SVG input when the input starts with
<svg.
The raster path applies merman's resvg-safe SVG cleanup before conversion.
Large Mermaid SVGs can be valid and still unsafe to rasterize at their intrinsic viewBox size.
Browsers usually paint the vector SVG inside a visible container; they do not have to allocate one
full-size pixmap up front. For preview-like PNG/JPG output, pass --raster-fit-width and/or
--raster-fit-height plus --scale for device-pixel ratio. For export-like output, the default
pixmap budget prevents accidental oversized allocations; use --raster-unbounded only when that
memory cost is intentional.
Compatibility Notes
merman-cli is browserless. It does not start Puppeteer, Chromium, or a Mermaid browser runtime.
For script compatibility with mmdc, --puppeteerConfigFile is accepted, the referenced file must
exist, and its contents must be valid JSON. The parsed values are intentionally ignored because this
renderer has no Puppeteer runtime to configure.
PDF output is generated through Rust SVG conversion rather than Chromium print-to-PDF, so it is not
intended to be pixel-identical to browser PDF output. The top-level default approximates the
upstream default page behavior; --pdfFit emits a chart-sized page.
The repository tracks the detailed mmdc compatibility matrix in
docs/alignment/CLI_COMPATIBILITY.md.