Skip to content
alexriosPublic

About

Pure Go offline Excalidraw renderer

Resources

Stars

9 stars

Watchers

0 watching

Forks

Repository files navigation

godraw

Install with Homebrew License: MIT

I don't like how messy JS environments and tooling are, so I built godraw, a pure Go CLI and library to render .excalidraw files to PNG and SVG offline without Node, Playwright, or Chrome.

It compiles to a single static binary (CGO_ENABLED=0) with the standard Excalidraw fonts embedded.

godraw @excalidraw/cli
Runtime Single static binary Node.js >=22 + Playwright + Chrome/Firefox
Network Offline by default Fetches fonts / cloud APIs
PNG 1x cold start ~50 ms ~5,800 ms
SVG + font subsetting ~30 ms ~5,700 ms
Library import "github.com/alexrios/godraw" CLI only

Install

brew install alexrios/tap/godraw
go install github.com/alexrios/godraw/cmd/godraw@latest
go get github.com/alexrios/godraw

CLI

godraw render drawing.excalidraw --out drawing.png
godraw render drawing.excalidraw --out drawing.svg --theme dark
godraw render deck.excalidraw --all-frames --out slides/
godraw render drawing.excalidraw --frame-id frame_1 --out frame.png --scale 2 --transparent
cat drawing.excalidraw | godraw render - --out - > drawing.png

Flags for godraw render <file>:

  • --out <path|-> (required): output file, directory (with --all-frames), or - for raw stdout bytes
  • --format <png|svg>: output format (inferred from --out extension by default)
  • --frame-id <id>, --all-frames: render a single frame or all frames
  • --scale <0..16>, --padding <0..1000>, --max-width <1..16384>, --max-height <1..16384>
  • --theme <light|dark>, --transparent
  • --fonts-url <dir|url|none> (EXCALIDRAW_FONTS_URL): optional source for Xiaolai CJK fonts
  • --timeout <ms>

Output files are written atomically and a JSON summary is printed to stdout. Passing --out - writes raw PNG/SVG bytes to stdout instead.

Go library

scene, err := godraw.ParseSceneFile("drawing.excalidraw")
res, err := godraw.RenderPNG(ctx, scene,
	godraw.WithScale(2),
	godraw.WithTheme(godraw.ThemeDark),
)
// Also: godraw.RenderSVG, godraw.RenderToImage, godraw.RenderAllFrames

License

MIT

About

Pure Go offline Excalidraw renderer

Resources

Stars

9 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages