Convert

Convert an Excalidraw scene to SVG.

A small utility, published because it solved a real problem here and the usual approach needs a DOM and about 1.4 MB of dependencies.

Download for macOS
v0.1.33 · .dmg · Apple Silicon & Intel
Signed & notarized by Apple · opens without a Gatekeeper warning
sha256 698955a0187bc039f4c74f5d05a9f10fbb27376a45788a0a241d1326b73873c7
Download for Windows instead
$curl -fsSL https://lucidtrain.com/install.sh | sh

Why not use Excalidraw's own exporter

exportToSvg needs a DOM and pulls in Excalidraw plus roughjs, which is a lot of machinery for a build step that runs occasionally and commits its output. For scenes generated programmatically the conversion is unusually clean, since roughness is zero and seeds are fixed, so there is no hand-drawn wobble to reproduce: the geometry in the file is the geometry.

What the script handles

Rectangles, ellipses, diamonds, lines, arrows with explicit points, standalone text with pre-measured widths, frames, and embedded images as data URLs inlined into symbol definitions. That covers everything the layout engine emits. Hand-drawn scenes with roughness applied are outside what it reproduces faithfully.

It is in the repository

scripts/excalidraw-to-svg.mjs in the landing site source. Plain Node, no dependencies, and it is what produces every diagram on this site. If it is useful to you, take it.

Fidelity

Comes throughDoes not
Rectangles, ellipses, diamondsYes
Lines and arrows with pointsYes, including arrowheads
Standalone textYes, with measured width
FramesYes, with names
Embedded imagesInlined as symbols
Hand-drawn roughnessAssumes roughness 0
Bound text inside containersExpects standalone text
Freedraw strokesNot handled

Usage

shell
$ node scripts/excalidraw-to-svg.mjs scene.excalidraw out.svg --no-docs
FAQ

Questions

Is the script open source?

It is in the landing site source in the repository, MIT along with the rest of it.

Does it need a browser?

No. Plain Node with no dependencies, which is the entire reason it exists.

Will it convert scenes I drew by hand?

Partially. It assumes roughness zero and standalone text, so a sketchy hand-drawn scene comes out looking different. Excalidraw's own exporter is the right tool there.

Related