Skip to content
Projects

excalidraw/mermaid-to-excalidraw

View on GitHub

About

Generate Excalidraw diagrams from Mermaid

Design & Media

How these counts are measured

What you can do

  • ✏️ Editable result: nodes become shapes, edges become arrows bound to them, labels stay where the layout put them.
  • 📊 Many diagram types: flowcharts (including swimlane-beta), sequence, class, ER and state diagrams, Gantt charts, quadrant charts and timelines. Other types are inserted as an image.
  • 🎨 Styles carry over: style, classDef and class colors, click links, and edges as elbow arrows on request.
  • ⚡ No Mermaid runtime: Pele parses and lays diagrams out without rendering them into the page, and each diagram type's code loads on first use.

Measured star growth

in 24h
+1
in 7 days
+1
in 15 days
+3
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README.md

Original

Mermaid to Excalidraw: turn Mermaid diagrams into shapes, arrows and text you can keep editing

Documentation · Playground · npm · Excalidraw+ · Excalidraw

npm license

Convert Mermaid diagram definitions into Excalidraw elements: shapes, arrows and text you can keep editing, not a picture of the diagram. It's what excalidraw.com runs when you paste a Mermaid definition onto the canvas.

Features

  • ✏️ Editable result: nodes become shapes, edges become arrows bound to them, labels stay where the layout put them.
  • 📊 Many diagram types: flowcharts (including swimlane-beta), sequence, class, ER and state diagrams, Gantt charts, quadrant charts and timelines. Other types are inserted as an image.
  • 🎨 Styles carry over: style, classDef and class colors, click links, and edges as elbow arrows on request.
  • ⚡ No Mermaid runtime: Pele parses and lays diagrams out without rendering them into the page, and each diagram type's code loads on first use.

Install

npm install @excalidraw/mermaid-to-excalidraw @excalidraw/excalidraw

It needs DOM APIs (DOMParser), so run it in a browser or with jsdom.

Quick start

import { parseMermaidToExcalidraw } from "@excalidraw/mermaid-to-excalidraw";
import { convertToExcalidrawElements } from "@excalidraw/excalidraw";

const definition = `flowchart LR
  A[Write the definition] --> B{Valid?}
  B -->|yes| C[Excalidraw elements]
  B -->|no| D[Parse error]`;

try {
  const { elements, files } = await parseMermaidToExcalidraw(definition, {
    elbow: true, // optional: draw edges as elbow arrows
  });

  excalidrawAPI.updateScene({
    elements: convertToExcalidrawElements(elements),
  });
  if (files) {
    excalidrawAPI.addFiles(Object.values(files));
  }
} catch (error) {
  // Not valid Mermaid syntax: show the error to the user
}

No code needed? The Excalidraw CLI runs it from your terminal: npx @excalidraw/cli mermaid flow.mmd --out flow.excalidraw.

Documentation

📚 plus.excalidraw.com/docs/mermaid-to-excalidraw

What changed in each release is in the changelog.

Contributing

See CONTRIBUTING.md for running the playground and the tests.

License

MIT

Explore related projects

Loading…