explaingit

terrastruct/d2

23,709GoAudience · developerComplexity · 2/5ActiveLicenseSetup · easy

TLDR

Write text descriptions of diagrams and D2 converts them into polished visuals automatically. Diagrams live as version-controlled text files alongside your code.

Mindmap

mindmap
  root((repo))
    What it does
      Text to diagram
      Auto layout
      Version control
    Use cases
      Architecture docs
      Database schemas
      API flows
      System topology
    Tech stack
      Go
      SVG export
      Layout engines
    Features
      Live preview
      Themes and fonts
      Editor plugins
      CLI tool

Things people build with this

USE CASE 1

Document software architecture by writing text descriptions that auto-layout into diagrams.

USE CASE 2

Create database schema diagrams and API flow charts that stay in sync with your codebase.

USE CASE 3

Build system topology and network diagrams without manual positioning or dragging shapes.

USE CASE 4

Track diagram changes over time by storing them as text files in version control.

Tech stack

GoSVGGraphVizCLI

Getting it running

Difficulty · easy Time to first run · 5min
Use freely for any purpose, including commercial use, as long as you keep the copyright notice and license text.

In plain English

D2 is a diagramming tool that lets you create technical diagrams by writing text rather than dragging and dropping shapes. You write a simple description of what connects to what, for example, "user -> database", and D2 converts that text into a polished visual diagram automatically. This approach means your diagrams live as readable text files that can be version-controlled alongside your code, making it easy to track changes over time. The language is designed for software architecture, network topology, and system documentation diagrams. You can describe boxes, arrows, labels, nested groups, and custom shapes, and choose from several automatic layout engines that arrange everything visually without manual positioning. D2 supports themes, custom fonts, and can export diagrams as SVG, PNG, or PDF. You would use D2 when you need to document how parts of a software system connect, architecture overviews, database schemas, API flow charts, and similar technical diagrams. It is especially useful in developer workflows where keeping documentation in sync with code matters. It runs as a command-line tool with live preview (a browser window that updates as you edit), can be embedded as a Go library, and has editor plugins for syntax highlighting. It is written in Go.

Copy-paste prompts

Prompt 1
Show me how to create a simple architecture diagram with D2 that shows a user connecting to a database and API server.
Prompt 2
How do I set up D2 with live preview in my editor so diagrams update as I type?
Prompt 3
Create a D2 diagram describing a microservices system with three services, a load balancer, and a shared database.
Prompt 4
How do I export a D2 diagram to PNG and customize the theme colors?
Prompt 5
Write a D2 diagram for an OAuth 2.0 flow showing user, client app, authorization server, and resource server.
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.