Install
There are more detailed install instructions for Mac, Windows, and Linux, using a variety of methods, here. This page is an abridged version.
Install script
The recommended way to install is to run our install script, which will figure out the best way to install based on your machine. E.g. if D2 is available through a package manager installed, it will use that package manager.
Follow the instructions, if any. Test your installation was successful by running d2 version.
If you want to uninstall:
For standalone releases from v0.8.2 onward, the installer checks the archive’s SHA-256
checksum before extracting it. To also verify that D2’s release workflow built the archive,
use --verify-provenance. This selects a standalone installation.
To remove this installation, use --method=standalone --uninstall. How verification works
Windows
On x64 Windows, download an MSI from the D2 releases page.
- Just for your account (v0.10.0 and later). Choose the file ending in
-windows-amd64-user.msi. It installs in%LOCALAPPDATA%\Programs\D2without administrator rights. - For all users. Choose the file ending in
-windows-amd64.msi. It requires administrator rights and installs in%ProgramFiles%\D2.
When upgrading, choose the same installation scope as before. If both copies are installed,
Windows normally finds the all-users copy first on PATH, even when the per-user copy is newer.
Open a new PowerShell or Command Prompt window and run where.exe d2 to see the search order,
then d2 --version to check the version that runs. To run the per-user copy directly in PowerShell,
use & "$env:LOCALAPPDATA\Programs\D2\d2.exe" --version.
For native ARM64, extract the -windows-arm64.tar.gz archive and run d2.exe from its bin directory.
GitHub Actions
The official d2lang/setup-d2 action installs the native D2 CLI on Linux, macOS, and
Windows runners. Later steps in the same job can run d2 directly.
Save this workflow as .github/workflows/render-d2.yml to check that an architecture.d2
file in your repository root renders to SVG on pull requests.
The @v1 ref selects the action version. Use version: latest or omit version to
install the latest stable D2 CLI release. To keep the same D2 version across runs,
set an exact version such as v0.10.0. For inputs, outputs, and runner requirements,
see the setup-d2 repository.
Install from source
Building D2 v0.10.0 from source requires Go 1.27.4 or newer.
You can also download precompiled binaries specific to your OS on the Github releases page: https://github.com/d2lang/d2/releases.
Try it out
Watch mode opens a browser that refreshes when you change input.d2. If it doesn’t open,
copy the full URL printed by d2 -w into your browser. Modify input.d2 as you go through
this tour to follow along.
In VS Code, install the official d2lang extension to preview the diagram beside your source.