Excalidraw CLI

excalidraw mermaid

Convert a Mermaid diagram into an Excalidraw scene, PNG or SVG.

Convert a Mermaid definition into editable Excalidraw elements, as the editor's Mermaid import does, and save it as a scene file or render it. Runs locally with an installed browser; no account or API key is required.

excalidraw mermaid [options] <file>
ArgumentDescription
<file>Mermaid definition file, or - to read stdin.
OptionDescription
--out <file>Write the result to a file (overwrites), or - for stdout. Required.
--format <format>Excalidraw, png, or svg; defaults to the --out extension, else excalidraw.
--elbowDraw flowchart edges and state transitions as elbow arrows.
--font-size <pixels>Font size of the diagram's text; default 20.
--padding <pixels>Padding in scene pixels; ignored for frames; default 20.
--scale <number>Resolution multiplier, up to 16; default 1.
--max-width <pixels>Maximum PNG width, up to 16384; default 16384.
--max-height <pixels>Maximum PNG height, up to 16384; default 16384.
--theme <theme>Light or dark; defaults to the scene's export preference.
--transparentExport with a transparent background.
--browser-path <path>Path to Chrome, Chromium, Edge, or Firefox; a binary named firefox is driven as Firefox. Environment variable: EXCALIDRAW_BROWSER_PATH.
--fonts-url <urls>Comma-separated mirror URLs or local folders for CJK fonts, or none. Environment variable: EXCALIDRAW_FONTS_URL.
--timeout <ms>Browser startup and render deadline; default 30000 ms.

Examples

excalidraw mermaid flow.mmd --out flow.excalidraw
excalidraw mermaid flow.mmd --out flow.png --scale 2
excalidraw mermaid flow.mmd --out flow.svg --elbow
echo "graph LR; A-->B" | excalidraw mermaid - --out - > flow.excalidraw
excalidraw mermaid flow.mmd --out flow.excalidraw && excalidraw scenes create --name "Flow" --collection-id <collectionId> --file flow.excalidraw

Notes

  • Flowcharts (including swimlane-beta), sequence, class, ER and state diagrams, Gantt charts, quadrant charts and timelines become editable shapes. Other types, such as pie charts, become one image.
  • The format follows the --out extension (.excalidraw, .json, .png, .svg) unless --format is set. Other extensions get an Excalidraw scene.
  • Uses an installed Chrome, Chromium, Edge or Firefox, also for scenes: it measures the text so shapes fit their labels.
  • With --out -, stdout gets only the scene, PNG or SVG, without the JSON summary. A syntax error names the line to fix.
  • More: /docs/cli/mermaid

Last updated on