# Install d2 with Homebrew, dnf, MacPorts, Nix, pacman, scoop, winget, zypper

Modern diagram scripting language that turns text to diagrams. Version 0.7.1 via Homebrew; verified from local package data.

## Install

```sh
sudo av install brew:d2
```

Additional install commands:

### macOS

- Homebrew (100%):

```sh
brew install d2
```

  Evidence: local Homebrew formula metadata

- MacPorts (94%):

```sh
sudo port install d2
```

  Evidence: MacPorts ports tree: graphics/d2/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1

### Linux

- dnf (92%):

```sh
sudo dnf install d2
```

  Evidence: Fedora Rawhide package metadata: d2 from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/e5ca8ce900cd68f5419e1c39ae517343100b306336cbaeb70a3c153121d95094-primary.xml.zst

- Nix (92%):

```sh
nix profile install nixpkgs#d2
```

  Evidence: nixpkgs package indexes: pkgs/by-name/d2/d2/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1

- pacman (92%):

```sh
sudo pacman -S d2
```

  Evidence: Arch Linux sync databases: d2 from https://geo.mirror.pkgbuild.com/extra/os/x86_64/extra.db.tar.gz

- zypper (92%):

```sh
sudo zypper install d2
```

  Evidence: openSUSE Tumbleweed package metadata: d2 from https://download.opensuse.org/tumbleweed/repo/oss/repodata/be8d3611d25469107f32075a1697e69ec57a2b850b42348a658cc671ad5ec2b50760d02c3e59524d50da9a11d5be799bdaffba2e166e8ca8858512e3c0bd665d-primary.xml.zst

### Windows

- Scoop (92%):

```sh
scoop install main/d2
```

  Evidence: Scoop official bucket manifest trees: bucket/d2.json from https://api.github.com/repos/ScoopInstaller/Main/git/trees/master?recursive=1

- winget (92%):

```sh
winget install --id Terrastruct.D2 -e
```

  Evidence: Windows Package Manager source index: Terrastruct.D2 from https://cdn.winget.microsoft.com/cache/source.msix

## Package facts

- **Package key:** brew:d2
- **Package manager:** Homebrew
- **Package manager page:** <https://formulae.brew.sh/formula/d2>
- **Version:** 0.7.1
- **Source summary:** Modern diagram scripting language that turns text to diagrams
- **Homepage:** <https://d2lang.com/>
- **Repository:** <https://github.com/terrastruct/d2>
- **Upstream docs:** <https://d2lang.com/>
- **License:** MPL-2.0
- **Source archive:** <https://github.com/terrastruct/d2/archive/refs/tags/v0.7.1.tar.gz>
- **Generated:** 2026-07-08T18:08:21+00:00

## Executables

- d2 (cli)
- d2 (alias)

## Build dependencies

- go

## Install behavior

- Post-install hook: not defined
- Bottle: available on arm64_linux, arm64_sequoia, arm64_sonoma, arm64_tahoe, arm64_ventura, sonoma, ventura, x86_64_linux

## Freshness

- Page generated: 2026-07-08
- Package-manager version: 0.7.1
- Local data: ok
- Upstream repository: https://github.com/terrastruct/d2
- Upstream latest detected: v0.7.1 (current)
- info: No package-manager update timestamp was available.
## Project history and usage

D2 is a modern diagram scripting language and CLI that turns text files into diagrams, especially for software architecture and documentation workflows.

### Project history

The D2 repository was created in 2022 by Terrastruct. The README presents D2 as a language, command-line renderer, and Go library, with official documentation, a playground, themes, language tooling, plugins, and export formats.

### Adoption history

D2 entered the diagram-as-code ecosystem as another text-to-diagram option alongside tools such as Graphviz and Mermaid. Its README emphasizes package-manager installation, editor/tooling support, and a list of open-source projects that document with D2.

### How it is used

The usual workflow is to write a .d2 file and run the d2 CLI to produce SVG, PNG, or PDF output. D2 can also be used as a Go library and can swap layout engines such as ELK or TALA.

### Why package nerds care

D2 is package-manager friendly because it ships as a single CLI for docs pipelines: install it with a system package manager, keep diagrams as source text, and regenerate images in builds or documentation sites.

### Timeline

- 2022: D2 repository created.
- 2022: Early v0.1.x tags published.
- 2025: v0.7.1 release published.

### Related projects

- D2 relates to diagram-as-code tools, Graphviz-style layout engines, ELK, TALA, Go documentation pipelines, and editor plugins.

### Sources

- <https://github.com/terrastruct/d2>
- <https://api.github.com/repos/terrastruct/d2>
- <https://github.com/terrastruct/d2/releases/tag/v0.7.1>
- <https://d2lang.com/>


## Security Notes

generalized runtime or code generation signal.

- **Geiger risk:** yellow / medium
- generalized runtime or code generation signal

## Source Database Details

- **Source Database:** Homebrew formula API
- **Tap:** homebrew/core
- **Full Name:** d2
- **Version Scheme:** 0
- **Revision:** 0
- **Head Version:** HEAD
- **Bottle Stable Root URL:** <https://ghcr.io/v2/homebrew/core>
- **Deprecated:** no
- **Disabled:** no
- **Keg Only:** no
- **URL Keys:** head, stable

## Other Package-Manager Records

- Nix - d2: normalized package name match | nixpkgs package indexes: pkgs/by-name/d2/d2/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1
- dnf - d2 - 0.6.9-8.fc44: normalized package name match | Fedora Rawhide package metadata: d2 from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/e5ca8ce900cd68f5419e1c39ae517343100b306336cbaeb70a3c153121d95094-primary.xml.zst | Modern diagram scripting language that turns text to diagrams | https://github.com/terrastruct/d2
- pacman - d2 - 0.7.1-2: normalized package name match | Arch Linux sync databases: d2 from https://geo.mirror.pkgbuild.com/extra/os/x86_64/extra.db.tar.gz | A modern diagram scripting language that turns text to diagrams | https://d2lang.com
- zypper - d2 - 0.7.1-1.4: normalized package name match | openSUSE Tumbleweed package metadata: d2 from https://download.opensuse.org/tumbleweed/repo/oss/repodata/be8d3611d25469107f32075a1697e69ec57a2b850b42348a658cc671ad5ec2b50760d02c3e59524d50da9a11d5be799bdaffba2e166e8ca8858512e3c0bd665d-primary.xml.zst | CLI tool and modern declarative language that turns text to diagrams | https://github.com/terrastruct/d2
- MacPorts - d2: normalized package name match | MacPorts ports tree: graphics/d2/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1
- Scoop - main/d2: normalized package name match | Scoop official bucket manifest trees: bucket/d2.json from https://api.github.com/repos/ScoopInstaller/Main/git/trees/master?recursive=1
- winget - Terrastruct.D2: normalized package name match | Windows Package Manager source index: Terrastruct.D2 from https://cdn.winget.microsoft.com/cache/source.msix


## Related links

- [Secret-risk packages](https://www.automicvault.com/pkg/secret-risk-packages/) - Has protected-tool coverage, approval-gate, or non-low Geiger security signals.
- [Terminal utility packages](https://www.automicvault.com/pkg/terminal-utilities/) - Matched terminal and command-line workflow metadata.
- [Text processing packages](https://www.automicvault.com/pkg/text-processing-tools/) - Matched text, document, or structured-data processing metadata.
- [Developer build packages](https://www.automicvault.com/pkg/developer-build-tools/) - Matched build, compiler, generator, or developer workflow metadata.
- [go](https://www.automicvault.com/pkg/brew/go/) - Build dependency declared by Homebrew.
- [ditaa](https://www.automicvault.com/pkg/brew/ditaa/) - Shares av.db curated category or tags: cli, developer-tools, diagramming, diagrams.
- [plantuml](https://www.automicvault.com/pkg/brew/plantuml/) - Shares av.db curated category or tags: cli, developer-tools, diagramming, diagrams.
- [clang-uml](https://www.automicvault.com/pkg/brew/clang-uml/) - Shares av.db curated category or tags: cli, developer-tools, diagramming.
- [diagram](https://www.automicvault.com/pkg/brew/diagram/) - Shares av.db curated category or tags: cli, developer-tools, diagramming.
- [dpic](https://www.automicvault.com/pkg/brew/dpic/) - Shares av.db curated category or tags: cli, developer-tools, diagramming.
- [eralchemy](https://www.automicvault.com/pkg/brew/eralchemy/) - Shares av.db curated category or tags: cli, developer-tools, diagramming.
- [graphviz2drawio](https://www.automicvault.com/pkg/brew/graphviz2drawio/) - Shares av.db curated category or tags: cli, developer-tools, diagramming.
- [likec4](https://www.automicvault.com/pkg/brew/likec4/) - Shares av.db curated category or tags: cli, developer-tools, diagramming.

## Combined YAML source

View the package source record on GitHub. [combined/d2.yml](https://github.com/automic-vault/db/blob/main/combined/d2.yml)


## Sources

- Nucleus package database
- Geiger risk classifier
- package-page enrichment
- curated package history
- package version freshness
- av.db category and tag curation
- package relationship graph
- external package-manager database matches
- cross-ecosystem install command graph
