d2-renderer - Private D2 Diagram Rendering over HTTP
D2 is a text language for architecture diagrams. It draws nested systems, database tables, and sequence diagrams, and each diagram lives as text next to your code. GitHub and GitLab show D2 code as plain text, and most online renderers need your diagram text on their servers.
I built d2-renderer, a free and open-source service that turns D2 text into SVG images over HTTP. You run it on your own machine or in your own cloud account. This post shows what d2-renderer fixes, what it can draw, and where to get it.
Navigate this post
What d2-renderer fixes
| Problem | What d2-renderer does |
|---|---|
| GitHub and GitLab show D2 code as plain text | Your docs site, editor, or build pipeline requests the drawn diagram as an SVG image from a web address. |
| Online renderers need your diagram text | You run the service yourself, so your architecture diagrams stay inside your own setup. |
| Installing D2, its layout engines, and fonts on every machine takes time | One container image includes the D2 compiler, three layout engines, and the fonts. |
Editors, builds, and documentation sites that use the same d2-renderer image get the same picture from the same text. A request is one HTTP call with the diagram text in it:
printf 'client -> server: request' \
| curl -X POST --data-binary @- http://localhost:8088/d2/svg -o diagram.svg
What you can draw
d2-renderer draws D2 diagrams such as nested architecture maps, sequence diagrams, and database tables. These two examples come from the d2-renderer repository.
A web application on AWS, with nested network zones:
A database schema, with tables, keys, and relationships:
Each request can also choose a layout engine, the part that decides where boxes and lines go (Dagre, ELK, or TALA), a color theme, and a hand-drawn sketch style.
Three ways to run it
| Option | When to choose it |
|---|---|
| Docker container | You use Docker or Podman. The image is built for both Intel and ARM processors, so it runs on Linux servers and Apple Silicon Macs. |
| Python script | You prefer no container. The script needs only Python's standard library and a local D2 install. |
| Google Cloud Run | You want one shared service for a team. Cloud Run stops the service when nobody uses it and starts it on the next request. Google Cloud permissions control who can call it. |
All three options answer the same requests. Moving from one to another changes only the address your tools call.
Security
d2-renderer assumes any diagram could come from someone else:
- Offline drawing: each diagram is drawn in an empty temporary folder, and the drawing step fetches nothing from the network. A diagram cannot make the server load other web addresses or read the server's files.
- Size and time limits: the service rejects diagrams larger than 256 KB and stops any drawing that runs longer than 20 seconds.
- No administrator rights: the container runs as an ordinary user.
- No stored cloud keys: each Cloud Run deploy signs in from GitHub Actions with a temporary token, so the repository holds no long-lived password.
Works with Lightweight Markdown Preview
Lightweight Markdown Preview, my VS Code extension, uses d2-renderer to draw D2 diagrams beside your Markdown as you type.

A third project, d2-architect, is a skill that teaches AI coding agents to add D2 diagrams to documentation. The skill writes the diagrams, the extension previews them, and d2-renderer draws them.
Get started
d2-renderer is on GitHub, with setup guides for Docker, Python, and Google Cloud Run. The container image is published as ghcr.io/kanad13/d2-renderer.
- d2-renderer source code and setup guides on GitHub
- d2-architect agent skill on GitHub
- Lightweight Markdown Preview on the Visual Studio Marketplace
Conclusion
d2-renderer draws D2 diagrams over HTTP from a service you run yourself, on your own machine or in your own cloud account. Find the source code and setup guides on GitHub.
References and further reading
Open the complete reference catalog
Primary Sources
- d2-renderer repository on GitHub
- D2 diagram language
- Google Cloud Run documentation
- d2-architect agent skill
Related Site Guides
- Lightweight Markdown Preview, One Year Later - The VS Code preview that draws D2 diagrams through d2-renderer
- Keeping My Projects on Current Versions: A Security Check-Up - A checklist for keeping small projects secure
- A Practical Docker Workflow for Vite Across Multiple Machines - Another Docker-based development setup