explaingit

terrastruct/d2

Analysis updated 2026-06-21

23,630GoAudience · developerComplexity · 2/5Setup · easy

TLDR

A text-to-diagram tool that converts simple text descriptions of connections into polished technical diagrams automatically, version-controllable, no manual layout needed, exports to SVG, PNG, or PDF.

Mindmap

mindmap
  root((repo))
    What it does
      Text to diagrams
      Auto layout
      Multiple export formats
    Diagram types
      Software architecture
      Network topology
      Database schemas
    Features
      Live preview
      Themes and fonts
      Multiple layout engines
    Audience
      Developers
      Technical writers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Write a text file describing your software architecture and generate a polished diagram without dragging any shapes.

USE CASE 2

Keep system documentation in sync with code by storing diagrams as text files in your git repository.

USE CASE 3

Export architecture or database schema diagrams as SVG or PNG for inclusion in wikis, slide decks, or docs.

What is it built with?

Go

How does it compare?

terrastruct/d2quii/learn-go-with-testscharmbracelet/gum
Stars23,63023,62723,562
LanguageGoGoGo
Setup difficultyeasyeasyeasy
Complexity2/52/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

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
I want to document my microservices architecture with D2. Write a D2 text file showing 4 services with a shared database and a message queue.
Prompt 2
Generate a D2 diagram for a REST API flow showing a client, an auth service, and a main API that writes to a database.
Prompt 3
Explain the D2 diagram language syntax in plain English, how do I create boxes, arrows, nested groups, and labels?
Prompt 4
I want to set up live preview with D2 so my diagram updates in the browser as I edit the file. Walk me through the command.

Frequently asked questions

What is d2?

A text-to-diagram tool that converts simple text descriptions of connections into polished technical diagrams automatically, version-controllable, no manual layout needed, exports to SVG, PNG, or PDF.

What language is d2 written in?

Mainly Go. The stack also includes Go.

How hard is d2 to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is d2 for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub terrastruct on gitmyhub

Verify against the repo before relying on details.