Diagram-as-code CLI for rendering D2 files to SVG, PNG, PDF, PowerPoint, GIF, or text.
$curl -fsSL https://d2lang.com/install.sh | sh -s --
AI Analysis
D2 is a diagram-as-code CLI and language for turning text files into rendered diagrams. It fits documentation, architecture, and presentation workflows where diagrams should live in version control and be generated on demand.
What It Enables
- Render
.d2source into SVG, PNG, PDF, PowerPoint, GIF, or plain-text diagram output from local files, stdin, or scripted build steps. - Format and validate diagram source, list themes and layout engines, and switch rendering options without hand-editing visual assets.
- Run live preview loops with
--watchor send a diagram to the hosted playground when iterating on docs, architecture diagrams, slides, or embedded site assets.
Agent Fit
- Render,
fmt, andvalidateflows are explicit non-interactive commands, and stdin or stdout support makes them easy to wrap in content-generation or CI pipelines. - Machine-readable output is limited: the public CLI mainly emits rendered artifacts and text, and the repo does not expose a documented JSON mode for normal automation.
- Best fit is generating and checking versioned diagram artifacts inside documentation or design workflows, not inspecting remote service state or driving operational control loops.
Caveats
--watchandplayopen browser-based preview flows, so those paths are less useful in fully headless environments.- PNG, PDF, PPTX, and GIF exports rely on browser rendering support, and extra layout plugins may come from separate
d2plugin-*binaries on$PATH.