d2 README

The project's README from github.com/d2lang/d2. As one markdown file: README.md.

D2

A modern diagram scripting language that turns text to diagrams.

Docs | Cheat sheet | Comparisons | Playground

ci weekly race tests release changelog npm version discord license

D2 Playground button

D2 feature showcase: Normal, Sketch, Animated, Terminal, Dark Mode, and ASCII

Open in Playground · Browse more examples

Trusted by

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.

NVIDIA Google Amazon GitLab Samsung Stripe Alibaba Group LangChain UK Ministry of Justice

Quickstart

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.

D2 as a library

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

Comparison

For a comparison against other popular text-to-diagram tools, see https://text-to-diagram.com.

Contributing

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

License

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!

Official plugins

Community integrations

Libraries and publishing

Editors and notes

Tools with D2 support

Misc

FAQ

d2 (d2lang/d2)

diagrams
Searching Database…

25.9K ·GitHub
What is this?D2 is an open-source diagram scripting language: you describe a diagram as plain text in a .d2 file, and it renders that text into a real diagram.
So is D2 a language I write, a tool I run, or a library?Both a language and a CLI: you write .d2 files and run the D2 executable to produce images, and Go programs can also embed D2 as a library.
How do I get my first diagram rendered?Install the CLI with the official install script (use --dry-run to preview what it does), then run it on a .d2 file — a browser tab opens with the SVG and live-reloads as you edit.
Do I need Go installed before using it?No. The install script ships a ready binary; Go is only needed if you install from source, which also skips the manpage.
Is it aimed at developers documenting software, or general diagramming?Mostly developers documenting software systems: the README stresses tooling for maintaining large diagrams, and projects like ElasticSearch, Sourcegraph, Temporal, and Tauri keep .d2 files in their repos.
The preview opens in a browser — does D2 itself need a browser or GUI to run?No browser or GUI is required — the browser tab is just an optional live preview, and D2 can run entirely server-side. The CLI installs on Windows, macOS, and Linux.
Does the CLI phone home or collect telemetry?No telemetry: after installation D2 makes no internet connections apart from an occasional version update check against GitHub.
What file formats can it export to?SVG, PNG, GIF, PDF, and PPTX, so one diagram source can feed docs, web pages, and slide decks.
Can diagrams get a hand-drawn look or math labels?Yes — sketch mode renders through a Go port of Rough.js for a hand-drawn style, and LaTeX labels are supported via a native MathJax port.
Can I try it without installing anything?Yes, the README links an online playground where you can write D2 and see the rendered diagram in the browser.
Creator
d2lang
Size
513.2 MB
Stars
25.9K
Age
4y
Commits · 90 Days