Try the Mermaid v13 beta β
TIP
Mermaid v13 is in beta. v13 is a full rewrite of the rendering engine, and it is now the line Mermaid is developed on. v12 keeps getting bug fixes. Your feedback in the v13 discussion and your bug reports shape the stable 13.0.0 release.
v13 renders without a browser DOM, so it works in Node, Deno, web workers and browsers. Its output is deterministic, and it has no third-party runtime dependencies. Please try the beta and tell us what breaks.
WARNING
This is a beta. Don't use it in production yet. APIs, output and defaults can still change between beta releases.
What works in the beta β
- 34 diagram types. Flowchart, sequence, ER, class, state, pie, quadrant chart, user journey, timeline, Gantt, gitGraph, mindmap, kanban, packet, radar, Sankey, treemap, Venn, Wardley map, XY chart, Cynefin, info, architecture, block, C4, requirement, agentflow, event modeling, Ishikawa (fishbone), railroad, swimlane, tree view, use case and JSON/YAML have v13 renderers. ZenUML is not ported yet: rendering it fails with an
UNSUPPORTED_DIAGRAMerror. - ESM, Node 20 or newer, and a CDN script. Install
mermaidand bundle it with your own bundler (Vite, webpack, esbuild, Rollup, β¦), or loaddist/mermaid.min.jsfrom a CDN: it is a small loader that fetches each diagram type the first time a page uses it. There is no "tiny" build. - New output formats. Every diagram renders to SVG. Flowchart, swimlane, sequence, ER, kanban, packet, info, block, C4, requirement, agentflow, Ishikawa, railroad, tree view, use case and JSON/YAML diagrams also render to text (ASCII or Unicode box drawing).
- Split into packages. Most people only need
mermaid: it includes the core and every diagram type, and loads each diagram the first time a page uses it. Icons, math, HTML labels, the hand-drawn look, ELK layouts and v12 click callbacks are optional plugins. See Packages.
Install β
All v13 packages share one dist-tag, v13-beta, which always points to the newest beta build. mermaid@latest stays on v12:
npm install mermaid@v13-beta --save-exact
# or
pnpm add mermaid@v13-beta --save-exactOr from a CDN, as in v12:
<script src="https://cdn.jsdelivr.net/npm/mermaid@v13-beta/dist/mermaid.min.js"></script>
<script>
mermaid.initialize({ startOnLoad: true });
</script>WARNING
When you add an optional package, install the v13-beta build of it together with the newest mermaid@v13-beta.
Beta builds β
We publish beta builds often. Each package has its own version number, 13.0.0-beta.N, which continues from its last alpha number. A change to one package also re-releases the packages that depend on it, so mermaid@v13-beta always pulls in a matching set. Mermaid's own packages depend on each other at exact versions.
| Build | Released | Packages |
|---|---|---|
13.0.0-beta.5 | 4 December 2026 | The first beta: 47 packages. mermaid, @mermaid-js/core, the class, Cynefin, ER, flowchart, journey, pie, quadrant, sequence, state and timeline diagram packages, the four language packages, layout-elk and the hand-drawn, icons, interactions and math plugins are at 13.0.0-beta.5. Gantt, gitGraph, info, kanban, mindmap, packet, radar, Sankey, treemap, Venn, Wardley map and XY chart are at 13.0.0-beta.4. Agentflow, architecture, block, C4, event modeling, Ishikawa, railroad, requirement, tree view and use case are at 13.0.0-beta.3. @mermaid-js/shared and @mermaid-js/plugin-autoload are at 13.0.0-beta.2. Two packages are new, at 13.0.0-beta.1: @mermaid-js/diagram-json and @mermaid-js/plugin-html-labels. |
Pin an exact build. Any build can change APIs or output, so a version range could pull in a breaking change without you noticing:
bashnpm install mermaid@13.0.0-beta.5 --save-exactMove to the newest build when you're ready, and read the release notes for what changed:
bashnpm install mermaid@v13-beta --save-exactSee which builds exist:
bashnpm view mermaid versions --json | grep 13.0.0-betaRetest on the newest build before you report a problem. It may already be fixed.
Alpha builds β
The alphas, under the dist-tag v13-alpha, came before the beta. They are no longer updated.
| Build | Released | Packages |
|---|---|---|
13.0.0-alpha.4 | 26 November 2026 | 45 packages. @mermaid-js/shared and @mermaid-js/plugin-autoload are new, at 13.0.0-alpha.1. |
13.0.0-alpha.3 | 11 November 2026 | 44 packages. 10 diagram packages are new, all at 13.0.0-alpha.1: agentflow, architecture, block, C4, event modeling, Ishikawa, railroad, requirement, tree view and use case. Swimlane diagrams come with @mermaid-js/diagram-flowchart. The 12 diagram packages first published in 13.0.0-alpha.2 are at 13.0.0-alpha.2, and all other packages are at 13.0.0-alpha.3. |
13.0.0-alpha.2 | 9 November 2026 | 34 packages. 13 diagram packages are new: Gantt, gitGraph, mindmap, kanban, packet, radar, Sankey, treemap, Venn, Wardley map, XY chart and info start at 13.0.0-alpha.1, and Cynefin at 13.0.0-alpha.2. All other packages are at 13.0.0-alpha.2. |
13.0.0-alpha.1 | 6 November 2026 | 21 packages. 17 are new in this build. |
13.0.0-alpha.0 | 4 November 2026 | mermaid, @mermaid-js/core, @mermaid-js/diagram-flowchart and @mermaid-js/plugin-interactions. The flowchart was the only diagram type. |
Render a diagram β
render, parse, initialize and run take the same arguments as in v12. Existing code like this keeps working:
import mermaid from 'mermaid';
mermaid.initialize({ theme: 'default' });
const { svg } = await mermaid.render(
'my-diagram',
`flowchart LR
A[Start] --> B{Works?}
B -- Yes --> C[Ship it]
B -- No --> D[File an issue]`
);
document.querySelector('#container').innerHTML = svg;run() and startOnLoad still render every .mermaid element on the page.
Things you can only do in v13 β
Render on the server, with no DOM or jsdom:
// Node script, no browser needed
import mermaid from 'mermaid';
const { svg, width, height, warnings } = await mermaid.render('id', 'flowchart LR\n A --> B');Render to text:
const { text } = await mermaid.render('id', 'flowchart LR\n A --> B', { format: 'ascii' });
console.log(text);Use the command line:
npx mermaid@v13-beta render diagram.mmd --format ascii
npx mermaid@v13-beta render diagram.mmd --format svg > diagram.svgUse structured errors. A failed render rejects with a MermaidError that has a code (SYNTAX, UNSUPPORTED_DIAGRAM, LIMIT, β¦) plus line and column, instead of raw parser text.
Keep a diagram live: mermaid.mount(element, text) renders into an element and gives you update(text) and destroy().
Packages β
Mermaid v13 is split into small packages. Most people only need mermaid. The other packages are optional add-ons, or building blocks for smaller bundles and editors. Each package has its own version number (see Beta builds), and npm install mermaid@v13-beta pulls in a matching set.
Which packages do I need? β
| You want to⦠| Install |
|---|---|
| Render diagrams on a site or in an app | mermaid |
| Render on a server or in a script, with no browser | mermaid (no jsdom or headless browser needed) |
| Render from the command line, as SVG or text | npx mermaid@v13-beta render diagram.mmd --format ascii |
| Keep a bundle small, with only some diagram types | mermaid (import mermaid/slim) + the @mermaid-js/diagram-* packages you need |
| Keep v12 click callbacks or actor menus | mermaid + @mermaid-js/plugin-interactions |
| Draw icons, math, the hand-drawn look or ELK layouts | mermaid + @mermaid-js/plugin-icons, plugin-math, plugin-hand-drawn or layout-elk |
| Keep v12's HTML labels | mermaid + @mermaid-js/plugin-html-labels |
Register the plugins your package.json lists, in Node | @mermaid-js/plugin-autoload |
| Add Mermaid editing to CodeMirror or Monaco | @mermaid-js/language-service-codemirror or @mermaid-js/language-service-monaco |
| Add Mermaid editing to any LSP editor | @mermaid-js/language-server |
mermaid, the core and the diagram packages have no third-party runtime dependencies. A few add-ons have one: roughjs (hand-drawn look), dompurify (HTML labels), elkjs (ELK) and vscode-languageserver (language server). The CodeMirror and Monaco packages use the editor you already have, as a peer dependency.
The main package β
| Package | What it does |
|---|---|
mermaid | The API (render, parse, initialize, run, mount) and every diagram type listed below. Renders in browsers, Node, Deno and workers without a DOM. It also includes the mermaid command line (mermaid render file.mmd --format svg|ascii) and mermaid/slim, the API without any diagrams. |
@mermaid-js/core | The shared engine: parsing tools, text measurement, layout, the SVG writer, themes and config. mermaid includes it. You only install it directly when you build a diagram plugin or use the language service. |
Diagram types β
mermaid already includes all of these. Install one yourself only when you use mermaid/slim:
import { createMermaid } from 'mermaid/slim';
import { flowchart } from '@mermaid-js/diagram-flowchart';
const mermaid = createMermaid({ diagrams: [flowchart] });| Package | Diagram | Text output (format: 'ascii') |
|---|---|---|
@mermaid-js/diagram-flowchart | flowchart, graph, swimlane-beta | Yes |
@mermaid-js/diagram-sequence | sequenceDiagram | Yes |
@mermaid-js/diagram-er | erDiagram | Yes |
@mermaid-js/diagram-class | classDiagram, classDiagram-v2 | Not yet |
@mermaid-js/diagram-state | stateDiagram, stateDiagram-v2 | Not yet |
@mermaid-js/diagram-pie | pie | No |
@mermaid-js/diagram-quadrant | quadrantChart | No |
@mermaid-js/diagram-journey | journey | No |
@mermaid-js/diagram-timeline | timeline | No |
@mermaid-js/diagram-gantt | gantt | No |
@mermaid-js/diagram-gitgraph | gitGraph | No |
@mermaid-js/diagram-mindmap | mindmap | No |
@mermaid-js/diagram-kanban | kanban | Yes |
@mermaid-js/diagram-packet | packet, packet-beta | Yes |
@mermaid-js/diagram-radar | radar-beta | No |
@mermaid-js/diagram-sankey | sankey, sankey-beta | No |
@mermaid-js/diagram-treemap | treemap, treemap-beta | No |
@mermaid-js/diagram-venn | venn-beta | No |
@mermaid-js/diagram-wardley | wardley-beta | No |
@mermaid-js/diagram-xychart | xychart, xychart-beta | No |
@mermaid-js/diagram-cynefin | cynefin-beta | No |
@mermaid-js/diagram-info | info | Yes |
@mermaid-js/diagram-architecture | architecture-beta | No |
@mermaid-js/diagram-block | block-beta, block | Yes |
@mermaid-js/diagram-c4 | C4Context, C4Container, C4Component, C4Dynamic, C4Deployment | Yes |
@mermaid-js/diagram-requirement | requirementDiagram | Yes |
@mermaid-js/diagram-agentflow | agentflow-beta | Yes |
@mermaid-js/diagram-eventmodeling | eventmodeling | No |
@mermaid-js/diagram-ishikawa | ishikawa, ishikawa-beta | Yes |
@mermaid-js/diagram-railroad | railroad-beta, railroad-ebnf-beta, railroad-abnf-beta, railroad-peg-beta | Yes |
@mermaid-js/diagram-treeview | treeView-beta | Yes |
@mermaid-js/diagram-usecase | usecase-beta | Yes |
@mermaid-js/diagram-json | json, json-beta, yaml, yaml-beta | Yes |
Each diagram package also has a /language entry with its editor support (see Editor tooling).
Optional plugins β
These add features that are not in mermaid by default. Install the ones you need, then register each one in code: installing a package alone does not enable it. In Node, @mermaid-js/plugin-autoload can register every plugin your package.json lists in one call.
| Package | What it does | Third-party dependency |
|---|---|---|
@mermaid-js/plugin-interactions | Brings back v12 click callbacks (click A callback, call fn(), including on Gantt tasks) and the sequence diagram actor menus. Plain links and tooltips work without it. | none |
@mermaid-js/plugin-icons | Draws Iconify icon packs: label icons such as fa:fa-car, the flowchart icon shapes, mindmap ::icon(), and architecture, tree view and use case icons. You register the packs with registerIconPacks, and each pack is loaded only when a diagram uses it. | none (you supply the packs) |
@mermaid-js/plugin-html-labels | v12's HTML labels (htmlLabels: true): raw HTML in a label is rendered, and a markdown string becomes HTML. Without it, every label is SVG text. The HTML enters the page when the diagram is mounted, so the string render() returns stays safe to insert. | dompurify |
@mermaid-js/plugin-math | TeX math in labels: $$β¦$$ is typeset by MathJax into SVG. MathJax loads only for diagrams that contain math. | none at install (MathJax is bundled and loaded on demand) |
@mermaid-js/plugin-hand-drawn | The hand-drawn look (handDrawn: true, or v12's look: handDrawn). It draws the same sketch every time for the same diagram. | roughjs |
@mermaid-js/layout-elk | ELK layouts: elk, elk.layered, elk.stress, elk.force, elk.mrtree, elk.sporeOverlap, elk.box, elk.rectpacking, elk.radial. Works for flowchart, class, state and ER diagrams. It keeps its v12 name and its v12 registration code. | elkjs |
import mermaid from 'mermaid';
import { interactions } from '@mermaid-js/plugin-interactions';
import { icons } from '@mermaid-js/plugin-icons';
import { htmlLabels } from '@mermaid-js/plugin-html-labels';
import elkLayouts from '@mermaid-js/layout-elk';
await mermaid.registerExternalDiagrams([interactions, icons, htmlLabels]);
mermaid.registerLayoutLoaders(elkLayouts);INFO
@mermaid-js/layout-elk also has v12 releases. npm install @mermaid-js/layout-elk (latest) still installs the v12 package (1.0.x). For v13, install @mermaid-js/layout-elk@v13-beta.
Registering plugins β
@mermaid-js/plugin-autoload registers, in Node, every Mermaid plugin that your app's package.json lists, with one call. It reads files, so it has no browser build: in a browser, register plugins in code as shown above.
import mermaid from 'mermaid';
import { autoload } from '@mermaid-js/plugin-autoload';
const warnings = await autoload(mermaid);Editor tooling β
New in v13: language support for editors that edit Mermaid text, with errors, completion, hover, go to definition, rename, folding and highlighting.
| Package | What it does |
|---|---|
@mermaid-js/language-service | The language support itself, for any editor: diagnostics, completion (including config: in front matter), hover, go to definition, references, rename, folding, semantic tokens, and a link between the cursor and the matching element in a live preview. Each diagram type's support comes from its diagram package and loads on demand. |
@mermaid-js/language-service-codemirror | All of the above for CodeMirror 6, as one mermaid() extension. |
@mermaid-js/language-service-monaco | All of the above for the Monaco editor, in one call: registerMermaid(monaco). |
@mermaid-js/language-server | A language server (LSP over stdio) for .mmd and .mermaid files, for any editor with an LSP client. Run it with mermaid-language-server --stdio. |
Before you upgrade an existing site β
Most v12 setups render without code changes. Check these first. Like everything on this page, they describe the beta and may change.
mermaidAPI.*has been removed. Use the top-level functions (initialize,render, β¦).- Labels are SVG text by default. For v12's HTML labels (
htmlLabels: true), register@mermaid-js/plugin-html-labels. - Click callbacks (
click A callback,call fn()) and sequence diagram actor menus need the@mermaid-js/plugin-interactionsplugin andsecurityLevel: 'loose'. Links (click A "url") and tooltips work without it. - Icons (
fa:fa-car, icon shapes), math ($$β¦$$), HTML labels, the hand-drawn look and ELK layouts each need their plugin, registered in code. See Optional plugins. securityLevelhas three levels:loose,strict(the default, matching v12's links) andstricter(relative links only).antiscriptandsandboxact asstrict, with a warning.- Custom CSS that targets element ids,
<marker>,.label-containeror the<style>element inside the SVG must move to the kept class names and the--mermaid-*CSS variables.
Give feedback β
Report bugs as issues. If a diagram renders differently from v12, or something breaks, open a v13 bug report. The template adds the v13 label and asks for:
- the exact build, e.g.
13.0.0-beta.5(npm ls mermaidshows it) - the diagram source
- what you expected, and what you got (a screenshot helps)
Ideas and opinions about v13 belong in the v13 discussion: which trade-offs you can live with, and what you need from v13 before 13.0.0.