One render in a warm process
13× faster
Median of 2076 diagrams. Both sides are warm: a Chromium page that stays open, and a Go process that stays running.
A Go port of mermaid 12.2.0
mmdg renders Mermaid to SVG, PNG, and vector PDF in pure Go. Compare its SVG output with mermaid in Chromium below. KaTeX math works on both page modes. ZenUML is available on the mermaid-cli page. No headless browser, no Node, no cgo.
go get github.com/bvolpato/mermaid-go-renderer
diagrams of mermaid's own test suite
0.88 ms against 11.5 ms in Chromium
than mmdc, which starts a browser
one static binary, or one Go import
01 Proof
A label that is one pixel wider moves a node, and then an edge. So the only useful measure is the output itself. Each square is one diagram of mermaid's own test suite. mmdg renders it, and the SHA-256 of the result is compared with the output of mermaid in Chromium 156.
The string that mermaid.render() returns in a plain Chromium page.
The end-to-end tests of mermaid
2143 of 2145
The examples of the mermaid documentation
594 of 596
Generated large diagrams
70 of 70
These results compare the current renderer with the recorded reference manifests. KaTeX math renders in diagram labels. ZenUML is available when the page is set to mermaid-cli.
go test -run TestCorpusParity .
The test needs no browser, no Node and no system fonts. The repository has the hash of every reference file.
| Reference | Corpus | Diagrams | Same bytes | Same error | Other result |
|---|---|---|---|---|---|
| mermaid.render() | The end-to-end tests of mermaid | 2145 | 2142 | 1 | 2 |
| mermaid.render() | The examples of the mermaid documentation | 596 | 576 | 18 | 2 |
| mermaid.render() | Generated large diagrams | 70 | 70 | 0 | 0 |
| mmdc 12 | The end-to-end tests of mermaid | 2145 | 2143 | 0 | 2 |
| mmdc 12 | The examples of the mermaid documentation | 596 | 592 | 2 | 2 |
| mmdc 12 | Generated large diagrams | 70 | 70 | 0 | 0 |
02 Speed
mermaid needs a page to measure text, so every tool around it carries a browser. mmdg has its own measurement engine. A render is a function call.
One render in a warm process
13× faster
Median of 2076 diagrams. Both sides are warm: a Chromium page that stays open, and a Go process that stays running.
Command-line run, flowchart to SVG
16× faster
Whole processes, same input and same output file. The measured command was mmdc 12.0.0. It starts a browser in each run.
Median time of one render, in milliseconds, on a logarithmic axis. Each row is one diagram type of the corpus.
| Diagram type | Diagrams | mermaid, ms | mmdg, ms |
|---|---|---|---|
| flowchart-v2 | 404 | 13.9 | 1.34 |
| classDiagram | 227 | 16.0 | 1.19 |
| er | 206 | 13.5 | 1.59 |
| sequence | 193 | 8.60 | 0.48 |
| requirement | 170 | 13.3 | 1.06 |
| stateDiagram | 144 | 21.0 | 1.06 |
| gitGraph | 135 | 7.90 | 0.19 |
| block | 58 | 9.40 | 0.39 |
| gantt | 52 | 3.00 | 0.18 |
| xychart | 48 | 3.80 | 0.25 |
| swimlane | 46 | 21.7 | 2.47 |
| agentflow | 38 | 13.8 | 1.48 |
| mindmap | 33 | 13.9 | 0.55 |
| c4 | 32 | 3.90 | 0.68 |
| timeline | 30 | 3.70 | 0.94 |
| usecase | 28 | 12.3 | 1.26 |
| treemap | 26 | 2.20 | 0.27 |
| pie | 24 | 2.10 | 0.10 |
| venn | 21 | 2.20 | 0.46 |
| architecture | 20 | 14.3 | 1.20 |
| journey | 18 | 4.80 | 0.26 |
| sankey | 18 | 2.60 | 0.07 |
| treeView | 15 | 1.70 | 0.12 |
| quadrantChart | 14 | 4.10 | 0.12 |
| ishikawa | 13 | 3.70 | 0.12 |
| cynefin | 12 | 3.20 | 0.18 |
| kanban | 11 | 4.10 | 0.22 |
| wardley | 10 | 2.00 | 0.19 |
| eventmodeling | 6 | 2.60 | 0.28 |
| packet | 6 | 2.60 | 0.06 |
| radar | 6 | 2.40 | 0.11 |
| railroad | 5 | 6.00 | 0.26 |
| info | 3 | 1.30 | 0.02 |
| railroadEbnf | 2 | 6.20 | 0.24 |
| railroadAbnf | 1 | 5.30 | 0.20 |
| railroadPeg | 1 | 7.20 | 0.29 |
Measured on 2026-11-09 on one machine, with mermaid 12.2.0 in Chromium 156.0.8078.4 and mmdc 12.0.0 for the command-line comparison. How they were measured.
03 Gallery
mmdg rendered these when this page was built. Try KaTeX math labels or a ZenUML diagram in the playground, alongside flowcharts, sequence diagrams, class diagrams, and more. Math labels work on both page modes. ZenUML uses the mermaid-cli page. The Go library and command also export vector PDF.
picks by type
dagre, ELK
sizes
Renderer
+Render(src) : string
+RenderPNG(src) : bytes
«interface»
Diagram
+Parse(text)
+Draw(ctx)
«interface»
Layout
+Run(graph)
Engine
+MeasureText(s) : Box
+BBox(node) : Box
Rendering
worker free
SVG ready
parse error
retry
Queued
Done
Failed
Parse
Layout
Draw
owns
writes
documents
has
TEAM
string
name
PK
string
channel
SERVICE
string
id
PK
string
tier
AUTHOR
string
login
PK
DIAGRAM
string
id
PK
string
type
REVISION
int
number
PK
date
created
mmdg
Diagrams
Flowchart
Sequence
Class and ER
Gantt
Layout
dagre
ELK
cose-bilkent
Output
SVG
PNG
Proof
SHA-256 of every file
No browser in the test
04 Playground
The renderer also compiles to WebAssembly. Load it and edit the diagram. The SVG comes from the same Go code, in your browser. Nothing is sent to a server.
Renderer
no
yes
miss
hit
Request
Token valid?
401 Unauthorized
In cache?
Diagram store
Render diagram
Write cache
Response
05 Inside
The renderer combines Go ports of Mermaid and browser code with bundled JavaScript for KaTeX and ZenUML and an original vector PDF writer. Tests compare renderer output with recorded results from upstream code. Some features and output paths have documented limits.
Mermaid text
Parser
Diagram code
Layout engines
SVG
PNG
Measurement engine
The parsers, the databases and the renderers of mermaid 12.2.0, for every diagram type, look and theme.
DOM, CSS cascade, font matching, HarfBuzz shaping with the arithmetic of Blink, and the float geometry of Skia. It answers the size questions that mermaid asks a page.
dagre, the layered algorithm of Eclipse ELK, cose-bilkent and fcose of cytoscape, swimlanes and tidy-tree. Each returns the bits of the original.
Number formatting, object key order, the sort of V8, the order of promises, and Math functions with the results of Chromium.
06 Use it
Install the library with go get github.com/bvolpato/mermaid-go-renderer. Install the command with Go or Homebrew below, or download a binary archive from the latest release. The renderer follows Mermaid 12.2.0. mmdg has its own release version. Run mmdg --version to check both versions.
import mermaid "github.com/bvolpato/mermaid-go-renderer"
src := `flowchart LR
A[Start] --> B{Done?}
B -->|yes| C[Stop]`
svg, err := mermaid.Render(src)
png, err := mermaid.RenderPNG(src, mermaid.WithScale(2))
pdf, err := mermaid.RenderPDF(src, mermaid.WithPDFPaperFormat("A4"))
pdfFromSVG, err := mermaid.SVGToPDF(svg)
RenderPDF creates a PDF from Mermaid source. SVGToPDF converts an existing SVG. WithPDFPaperFormat selects a fixed page size. Without it, the page fits the diagram. PDF uses vector paths and TrueType fonts or Type 3 glyph subsets where possible. Unsupported fonts are outlined, and some contextual glyphs or ligatures may not extract as the original text. Drop shadows are flat silhouettes. Other filter graphs and image elements, including data URLs, are omitted. It needs Go 1.27.
go install github.com/bvolpato/mermaid-go-renderer/cmd/mmdg@latest
brew install bvolpato/tap/mmdg
mmdg -i diagram.mmd -o diagram.svg
mmdg -i diagram.mmd -o diagram.png -s 2
mmdg -i diagram.mmd -e pdf -o diagram.pdf --pdf-paper-format A4
mmdg -i README.md -o README.out.md -a images
Use --pdf-paper-format to select a fixed page size. Without it, the PDF page fits the diagram. The -f flag remains accepted for compatibility.