Find your next open-source project

Search by name, purpose, or keyword, or paste a GitHub URL. Start with / to search agent skills (e.g. /pdf)

A text-to-diagram scripting language for developers who define architecture in version-controlled text files.

This project ships 1 agent skillsSkill list and install →
26,031
797
Go
MPL-2.0
4 years old

What D2 does

D2 is a diagram scripting language: you describe shapes and connections in a .d2 file, and the CLI renders them to SVG, PNG, GIF, MP4, WebM, PDF, PPTX, or ASCII text. The layout engines are bundled and run natively in Go, so no browser is required. It is aimed at developers and technical writers who want diagrams stored next to code, reviewed in pull requests, and regenerated from source rather than edited by hand in a GUI.

Three bundled layout engines are selectable with --layout: Dagro (default), elk-go, and TALA, the last designed for software architecture diagrams. Sequence diagrams and grids get dedicated layout handling. Animated output is also supported through vars.d2-config animation settings and connection icons.

Quickstart

On macOS or Linux, install with the script:

curl -fsSL https://d2lang.com/install.sh | sh -s --

On x64 Windows, use the MSI from the latest release; other platforms and package managers are covered in the installation guide. If you have uv, uvx d2lang hello.d2 runs the CLI without a separate install.

Create hello.d2 containing x -> y -> z, then render it:

d2 hello.d2

This writes hello.svg next to the source. For a live preview, run d2 --watch hello.d2 and edit the file. d2 validate hello.d2 reports errors and warnings, with --max-warnings 0 to fail a CI check and --json for machine-readable diagnostics. Try the syntax in the playground before installing.

Embedding and exports

Go programs can render through d2lib and JavaScript/TypeScript through @d2lang/d2; both expose a validation call that returns source ranges and rule codes, so diagram checking can run without rendering. See the Go examples and the D2.js usage guide.

Export format is chosen by the output extension. Animated SVGs, GIFs, MP4s, and WebM files can be produced with configured intervals and durations; MP4/WebM export requires FFmpeg 5.1 or newer on PATH with the relevant encoder. d2 storyboard renders a contact sheet of animation boards, and d2 lint --motion flags crowded transitions and short-lived labels.

Constraints

D2 is open source under MPL-2.0. Renders use the bundled "Source Sans Pro" font by default; other fonts are configured under d2renderers/d2fonts, and themes live in d2themes. The tool does not use an internet connection after installation except to periodically check GitHub for version updates, and it does not collect telemetry. Video export, animation, and storyboard inspection are the parts that add external dependencies or heavier render time.

HotRepo's take

The repository has 26,029 stars and 797 forks, and in the Go weekly ranking recorded for 2026-12-04 it placed 15th with 80 stars gained that week. That shows sustained attention rather than a one-off spike, and the README's list of adopters—NVIDIA, Google Cloud, AWS Labs, GitLab, Stripe, Alibaba, and others—indicates real integration work around the core language. For a text-to-diagram tool, the practical differentiator is the breadth of output formats and the native, browser-free render pipeline; the tradeoff is that animated and video exports pull in more setup than a plain SVG render.

Written by AI from the project's public information and HotRepo's records, updated . The project's own docs are the source of truth.

You might also like

  1. lukendeasy/open-diagramPython library that draws dense architecture diagrams and checks each layout before export.Python135
  2. tt-a1i/archifyTurns an idea, plan, or codebase into a shareable interactive HTML diagram through your coding agent.JavaScript88,713
  3. likec4/likec4A modelling language and toolchain that generates live C4-style architecture diagrams from code, aimed at software architects and developers.TypeScript6,412
  4. mermaid-js/mermaidGenerates flowcharts, sequence diagrams, Gantt charts and other diagrams from Markdown-like text, aimed at developers and technical writers.TypeScript91,007
  5. MitchStares/drawio-designAn agent skill that builds native, editable draw.io diagrams from plain-language requests across 52 visual types.Python106