About this project

D2 is a domain-specific language for generating diagrams from text. Users write .d2 files describing nodes, connections, shapes, and styles, and D2 renders them into visual diagrams. Key capabilities include: - CLI usage: Run `d2 --watch in.d2 out.svg` to produce SVGs with live-reload in a browser window on file changes. - Export formats: SVG, PNG, GIF, PDF, and PPTX. - Layout engines: Three bundled engines — Dagro (default, hierarchical/layered layouts, a native Go port of Dagre), ELK (native Go port suited for node-link diagrams with direction and ports), and TALA (opt-in, designed specifically for software architecture diagrams). Specialized layouts for sequence diagrams and grids are also supported. - Themes: A variety of official themes ship with D2 for out-of-the-box styling. - Fonts: Ships with "Source Sans Pro"; alternative fonts can be configured. - Language tooling: The parser reports multiple errors, includes an autoformatter, syntax highlighting, and planned LSP support. VSCode and Vim extensions are available as official plugins. - Go library: D2 can be used as a Go library to produce diagrams programmatically. - Sketch-mode rendering via rough-go (a native Go port of Rough.js) and LaTeX label support via mathjax-go (a native Go port of MathJax). Installation is available via an install script (`curl -fsSL https://d2lang.com/install.sh | sh -s --`), Go source (`go install github.com/d2lang/d2@latest`), or release source builds. An uninstall option is also provided. A broad ecosystem of community plugins exists, including integrations for Obsidian, MdBook, MkDocs, VitePress, Hexo, Pandoc filters, Confluence, Logseq, Zed, Emacs, tree-sitter grammar, and exporters for Postgres schemas, MongoDB, Structurizr, AsyncAPI, ROS2, and CIL assemblies. A web playground is available at play.d2lang.com. D2 is used in documentation by notable open-source projects including ElasticSearch, Sourcegraph, Temporal, Tauri, IntelliJ, Coder, UC Berkeley, LocalStack, and Dagger. It is licensed under Mozilla Public License 2.0. No telemetry is collected; D2 does not use an internet connection after installation except for periodic version update checks from GitHub.