The project's README from github.com/d2lang/d2. As one markdown file: README.md.
Docs | Cheat sheet | Comparisons | Playground
Open in Playground · Browse more examples
Organizations around the world use D2 to power blog posts and docs both internally and externally. D2 is also integrated into many popular tools and services.
On macOS or Linux, run the install script.
curl -fsSL https://d2lang.com/install.sh | sh -s --
On x64 Windows, download the MSI installer from the latest release. The installation guide covers other platforms, package managers, and uninstalling.
Save x -> y -> z in a file named hello.d2, then run the following command to create hello.svg.
d2 hello.d2
With uv, run the native CLI directly with uvx d2lang hello.d2.
Run d2 validate hello.d2 to check a diagram for errors and warnings. Add
--max-warnings 0 to fail a CI check on warnings, or --json to read the diagnostics programmatically.
For a live preview in your browser, run d2 --watch hello.d2 and edit the file.
You can render diagrams from Go with d2lib or from JavaScript and TypeScript with
@d2lang/d2. To check source without rendering, call d2compiler.Validate(path, reader, opts)
in Go or await d2.validate(source) in JavaScript. Both return a report with source ranges and rule codes.
Go examples · D2.js usage guide
For a comparison against other popular text-to-diagram tools, see https://text-to-diagram.com.
Contributions are welcome! See ./docs/CONTRIBUTING.md. Parser and editor authors can use the structural grammar, lexical grammar, and conformance cases.
D2 is an independent open-source project fiscally sponsored by Hack Club. Sponsor D2
Open sourced under the Mozilla Public License 2.0. See ./LICENSE.txt.
We are constantly working on new plugins, integrations, extensions. Contributions are welcome in any official or community plugins. If you have somewhere in your workflow that you want to use D2, feel free to open a discussion. We have limited bandwidth and usually choose the most high-demand ones to work on. If you make something cool with D2 yourself, let us know and we'll be happy to include it here!
npx skills add d2lang/d2 (for Claude Code, Codex, Cursor, Copilot, Gemini CLI, and other Agent Skills clients). Skill sourceLibraries and publishing
Editors and notes
Tools with D2 support