Skip to main content

D2 Tour

D2 is a diagram scripting language that turns text to diagrams. It stands for Declarative Diagramming. Declarative, as in, you describe what you want diagrammed, it generates the image.

For example, download the CLI, create a file named input.d2, copy paste the following, run this command, and you get the image below.

NETWORKUSERAPI SERVERLOGSCELL TOWERONLINE PORTALDATA PROCESSORSATELLITESTRANSMITTERUISTORAGE SENDSENDSENDPHONE LOGSMAKE CALL ACCESSDISPLAYPERSIST

Using the CLI watch mode

D2 CLI

You can finish this tour in about 5-10 minutes, and at the end, there's a cheat sheet you can download and refer to. If you want just the bare essentials, Getting Started takes ~2 mins.

info

The source code for D2 is hosted here: https://github.com/terrastruct/d2.

The source code for these docs are here: https://github.com/terrastruct/d2-docs.

info

For each D2 snippet, you can hover over it to open directly in the Playground and tinker.

There's some exceptions like snippets that use imports.