D2 is a diagram scripting language that converts text descriptions into visual diagrams.
D2 solves the problem of creating and maintaining diagrams through code rather than graphical interfaces. It works by parsing a text-based syntax into structured diagram definitions, then rendering them to visual formats. This approach keeps diagrams version-controllable and enables programmatic generation. The tool supports multiple export formats and includes a live-reload development experience through its CLI, allowing developers to see changes to their diagram source reflected immediately in a browser.
D2 suits teams and projects that prioritize documentation-as-code workflows, where diagrams need to be tracked alongside source code and regenerated as part of build processes. It is particularly valuable for software architecture documentation, system design, and any scenario where diagrams are frequently updated. The project can be used both as a standalone CLI tool and as a Go library for embedding diagram generation into applications. D2 provides built-in themes for styling diagrams and ships with a default font, with options to customize both. The README references a comparison resource but does not make specific claims about how D2 differs from alternatives.
The project maintains active development with regular updates to both the core language and ecosystem. The tool has accumulated a collection of official plugins and community-contributed plugins that extend its capabilities. Documentation is comprehensive, including a cheat sheet and an interactive playground for learning the syntax. The codebase is written in Go and remains open to contributions, with clear installation documentation covering multiple operating systems and installation methods.