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.
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 through | Does not | |
|---|---|---|
| Rectangles, ellipses, diamonds | Yes | |
| Lines and arrows with points | Yes, including arrowheads | |
| Standalone text | Yes, with measured width | |
| Frames | Yes, with names | |
| Embedded images | Inlined as symbols | |
| Hand-drawn roughness | Assumes roughness 0 | |
| Bound text inside containers | Expects standalone text | |
| Freedraw strokes | Not handled |
Usage
Questions
Related
- Convert Code to a DiagramThe general case: point it at code and get a diagram of what is there rather than what you remember building.
- Convert a Diagram into CodeThe direction almost nothing else does: the diagram stops being documentation and becomes the instruction.
- Convert Terraform to an Architecture DiagramTerraform records dependencies explicitly through references, so the edges are read rather than inferred. It is one of the most reliable sources there is.
- Convert Mermaid to ExcalidrawUseful when a Mermaid diagram has outgrown what Mermaid's layout can render legibly.