Clean, deterministic, browser-free renderer for .excalidraw files (PNG/SVG).
Project description
excalidraw-render
Clean, deterministic, browser-free renderer for .excalidraw files. Pure Python + cairosvg. No Node, no headless browser, no node-canvas.
pip install excalidraw-render
excalidraw-render diagram.excalidraw # → diagram.png
excalidraw-render diagram.excalidraw -f svg # → diagram.svg
excalidraw-render diagram.excalidraw --width 1200 # PNG at 1200px wide
excalidraw-render ./docs/ # batch: every .excalidraw → .png
Why this exists
The Excalidraw ecosystem's existing exporters either need Node + node-canvas (excalidraw_export) or a headless browser running React (@excalidraw/excalidraw). Both are heavy, fragile in CI, and slow to start.
excalidraw-render is Python + cairosvg. Single-digit-megabyte install, instant startup, no native canvas libs, no Chromium. Useful for:
- Static-site generators (Hugo, MkDocs, Sphinx) baking
.excalidrawto PNG at build time - CI/screenshot pipelines where pulling Chromium is overkill
- Doc + slide generators that want predictable, deterministic vector output
- Terminal viewers (Kitty, iTerm2, Sixel) — coming in v0.2
Trade-off: no hand-drawn style
Excalidraw's signature squiggly look comes from roughjs, a JavaScript library with no native Python port. excalidraw-render produces clean vector output instead. This is a deliberate trade-off — clean output is what most doc / slide / report pipelines actually want, and skipping roughjs removes the heaviest dependency.
A pure-Python roughjs port (pyroughjs) is on the v0.2 roadmap. Until then, if you need the hand-drawn look, use Excalidraw's official export.
Comparison
excalidraw-render |
excalidraw_export |
@excalidraw/excalidraw |
|
|---|---|---|---|
| Language | Python | Node | React + Node |
| Hand-drawn (roughjs) | No (v0.2 stretch) | Yes | Yes |
| PNG output | Yes | via rsvg-convert |
Yes |
| SVG output | Yes | Yes | Yes |
| PDF output | v0.2 | via rsvg-convert |
No |
| Headless browser needed | No | No | Yes |
| Native canvas / image libs | No | Yes (node-canvas) |
No |
| Install size | ~10 MB | ~150 MB | Depends |
| Batch / watch mode | Batch ✓ / watch v0.2 | No | No |
| Terminal protocols | v0.2 (iTerm / Kitty / Sixel) | No | No |
Install
pip install excalidraw-render
On Linux you may need libcairo2:
sudo apt-get install libcairo2 # Debian / Ubuntu
sudo dnf install cairo # Fedora
sudo pacman -S cairo # Arch
On macOS, Cairo is typically already present via Homebrew. If not:
brew install cairo
Usage
CLI
# Single file → PNG next to source
excalidraw-render diagram.excalidraw
# Specify output + format
excalidraw-render diagram.excalidraw -o /tmp/out.svg -f svg
# Higher resolution PNG
excalidraw-render diagram.excalidraw --width 1600
# Or scale instead of fixed width
excalidraw-render diagram.excalidraw --scale 2.0
# Transparent background
excalidraw-render diagram.excalidraw --no-background
# Batch mode: every .excalidraw in a directory
excalidraw-render ./docs/diagrams/ -o ./public/diagrams/
Python API
from excalidraw_render.render import load_scene, render_svg, render_png
scene = load_scene("diagram.excalidraw")
# SVG as a string
svg = render_svg(scene)
# PNG to a file
render_png(scene, "diagram.png", width=1200)
# PNG to a binary stream
import io
buf = io.BytesIO()
render_png(scene, buf, scale=2.0)
What's supported in v0.1
Elements: rectangle, ellipse, diamond, arrow, line, text, freedraw, image, frame.
Arrowheads: arrow, triangle, triangle_outline, bar, dot, diamond, diamond_outline, crowfoot_one, crowfoot_many, crowfoot_one_or_many.
Styling: stroke color/width, fill color, stroke style (solid/dashed/dotted), opacity, per-element rotation.
Text: multi-line, text-align (left/center/right), vertical-align (top/middle/bottom), Excalidraw font families mapped to web-safe fonts.
Freedraw: smooth path via Catmull-Rom → cubic Bezier conversion.
Image: embedded raster data from the scene's files dict.
Frame: dashed boundary box with optional label.
Coverage matrix: docs/elements.md.
What's not supported yet
Documented in CHANGELOG.md. Highlights:
- Roughness / hand-drawn look (v0.2 — needs roughjs port)
- PDF / JPEG output (v0.2)
- Hachure / cross-hatch / zigzag / dots fill patterns (currently fall back to solid)
- Container-bound text positioning fidelity (padding-aware layout)
- Terminal output (iTerm / Kitty / Sixel) — v0.2
- Markdown preprocessor subcommand — v0.2
- Watch mode — v0.2
Contributing
This is pre-alpha and breaking changes between minor versions are likely until v1.0. Issues, ideas, and PRs welcome — please file at https://github.com/shivama205/excalidraw-render/issues.
Local dev:
git clone https://github.com/shivama205/excalidraw-render
cd excalidraw-render
python -m venv .venv && .venv/bin/pip install -e ".[dev]"
.venv/bin/pytest
.venv/bin/ruff check src tests
.venv/bin/mypy src
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file excalidraw_render-0.1.2.tar.gz.
File metadata
- Download URL: excalidraw_render-0.1.2.tar.gz
- Upload date:
- Size: 48.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30d2b7a7cfac3509fd5b43e7c59fdde4ac7f3aec2ea25aaffdc1052a4d0a354d
|
|
| MD5 |
5ab13ff9c64b78b3a6d672f865895965
|
|
| BLAKE2b-256 |
3e2075e70a3c869283dc26405f0d3c965f339041767b08a5cb9b37a702d49555
|
File details
Details for the file excalidraw_render-0.1.2-py3-none-any.whl.
File metadata
- Download URL: excalidraw_render-0.1.2-py3-none-any.whl
- Upload date:
- Size: 21.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84cf9e13f28e76d407fbd992c4a584b1b067f800e7b992c527d96ec2552cd9e3
|
|
| MD5 |
4bbab3734250e0c8d1dbba48f8ad2b5e
|
|
| BLAKE2b-256 |
ad63f12e57daba4345d7a139ce673b59c18ed199a779d8dc44851e4ae87170fe
|