- Notifications
You must be signed in to change notification settings - Fork602
D2 is a modern diagram scripting language that turns text to diagrams.
License
terrastruct/d2
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
- What does D2 look like?
- Quickstart
- Install
- D2 as a library
- Themes
- Fonts
- Export file types
- Language tooling
- Plugins
- Comparison
- Contributing
- License
- Related
- FAQ
- Notable open-source projects documenting with D2
vars: {d2-config: {layout-engine:elk# Terminal theme codetheme-id:300 }}network: {cell tower: {satellites: {shape:stored_datastyle.multiple:true }transmittersatellites->transmitter:sendsatellites->transmitter:sendsatellites->transmitter:send }online portal: {ui: {shape:hexagon} }data processor: {storage: {shape:cylinderstyle.multiple:true } }cell tower.transmitter->data processor.storage:phone logs}user: {shape:personwidth:130}user->network.cell tower:make calluser->network.online portal.ui:access {style.stroke-dash:3}api server->network.online portal.ui:displayapi server->logs:persistlogs: {shape:page;style.multiple:true}network.data processor->api server
Open inplayground
For more examples, see./docs/examples.
The most convenient way to use D2 is to just run it as a CLI executable toproduce SVGs from.d2 files.
# First, install D2curl -fsSL https://d2lang.com/install.sh| sh -s --echo'x -> y -> z'> in.d2d2 --watch in.d2 out.svg
A browser window will open without.svg and live-reload on changes toin.d2.
The easiest way to install is with our install script:
curl -fsSL https://d2lang.com/install.sh| sh -s --You can run the install script with--dry-run to see the commands that will be usedto install without executing them.
Or if you have Go installed you can install from source though you won't get the manpage:
go install oss.terrastruct.com/d2@latest
You can also install a release from source which will include manpages.See./docs/INSTALL.md#source-release.
To uninstall with the install script:
curl -fsSL https://d2lang.com/install.sh| sh -s -- --uninstallFor detailed installation docs, see./docs/INSTALL.md.We demonstrate alternative methods and examples for each OS.
As well, the functioning of the install script is described in detail to alleviate anyconcern of its use. We recommend using your OS's package manager directly instead forimproved security but the install script is by no means insecure.
In addition to being a runnable CLI tool, D2 can also be used to produce diagrams fromGo programs.
For examples, see./docs/examples/lib. Thisblogpost also demos acomplete, runnable example of using D2 as a library for a real-world use case.
D2 includes a variety of official themes to style your diagrams beautifully right out ofthe box. See./d2themes to browse the available themes and make orcontribute your own creation.
D2 ships with "Source Sans Pro" as the font in renders. If you wish to use a differentone, please see./d2renderers/d2fonts.
D2 currently supports SVG, PNG and PDF exports. More coming soon.
D2 is designed with language tooling in mind. D2's parser can parse multiple errors from abroken program, has an autoformatter, syntax highlighting, and we have plans for LSP's andmore. Good language tooling is necessary for creating and maintaining large diagrams.
The extensions for VSCode and Vim can be found in theRelated section.
D2 is designed to be extensible and composable. The plugin system allows you tochange out layout engines and customize the rendering pipeline. Plugins can either bebundled with the build or separately installed as a standalone binary.
Layout engines:
- dagre (default, bundled): A fast, directed graphlayout engine that produces layered/hierarchical layouts. Based on Graphviz's DOTalgorithm.
- ELK (bundled): A directed graph layout engineparticularly suited for node-link diagrams with an inherent direction and ports.
- TALA (binary): Novel layout engine designedspecifically for software architecture diagrams. Requires separate install, visit theGithub page for more.
D2 intends to integrate with a variety of layout engines, e.g.dot, as well assingle-purpose layout types like sequence diagrams. You can choose whichever layout engineyou like and works best for the diagram you're making.
For a comparison against other popular text-to-diagram tools, seehttps://text-to-diagram.com.
Contributions are welcome! See./docs/CONTRIBUTING.md.
Open sourced under the Mozilla Public License 2.0. See./LICENSE.txt.
We are constantly working on new plugins, integrations, extensions. Contributions arewelcome in any official or community plugins. If you have somewhere in your workflow thatyou want to use D2, feel free to open a discussion. We have limited bandwidth and usuallychoose the most high-demand ones to work on. If you make something cool with D2 yourself,let us know and we'll be happy to include it here!
- VSCode extension:https://github.com/terrastruct/d2-vscode
- Vim extension:https://github.com/terrastruct/d2-vim
- Obsidian plugin:https://github.com/terrastruct/d2-obsidian
- Slack app:https://d2lang.com/tour/slack
- Discord plugin:https://d2lang.com/tour/discord
- Tree-sitter grammar:https://github.com/ravsii/tree-sitter-d2
- Emacs major mode:https://github.com/andorsk/d2-mode
- Goldmark extension:https://github.com/FurqanSoftware/goldmark-d2
- Telegram bot:https://github.com/meinside/telegram-d2-bot
- Postgres importer:https://github.com/zekenie/d2-erd-from-postgres
- Structurizr to D2 exporter:https://github.com/goto1134/structurizr-d2-exporter
- MdBook preprocessor:https://github.com/danieleades/mdbook-d2
- ROS2 D2 Exporter:https://github.com/Greenroom-Robotics/ros-d2
- D2 org-mode support:https://github.com/xcapaldi/ob-d2
- Python D2 diagram builder:https://github.com/MrBlenny/py-d2
- Clojure D2 transpiler:https://github.com/judepayne/dictim
- JavaScript D2 diagram builder:https://github.com/Kreshnik/d2lang-js
- C# & dotnet SDK:https://github.com/Stephanvs/d2lang-cs
- Maven plugin:https://github.com/andrinmeier/unofficial-d2lang-maven-plugin
- Confluence plugin:https://github.com/andrinmeier/unofficial-d2lang-confluence-plugin
- CIL (C#, Visual Basic, F#, C++ CLR) to D2:https://github.com/HugoVG/AppDiagram
- D2 Snippets (for text editors):https://github.com/Paracelsus-Rose/D2-Language-Code-Snippets
- Mongo to D2:https://github.com/novuhq/mongo-to-D2
- Pandoc filter (TypeScript):https://github.com/ram02z/d2-filter
- Pandoc filter (Python):https://github.com/fliiiix/pandoc-d2-filter
- Logseq-D2:https://github.com/b-yp/logseq-d2
- ent2d2:https://github.com/tmc/ent2d2
- MkDocs Plugin:https://github.com/landmaj/mkdocs-d2-plugin
- Remark Plugin:https://github.com/mech-a/remark-d2
- VitePress Plugin:https://github.com/BadgerHobbs/vitepress-plugin-d2
- Zed extension:https://github.com/gabeidx/zed-d2
- Hexo blog extension:https://github.com/leverimmy/hexo-d2
- Rehype Plugin:https://github.com/stereobooster/beoe/tree/main/packages/rehype-d2
- AsyncAPI to D2:https://github.com/holydocs/messageflow
- Database Schemas to D2:https://github.com/holydocs/dberd
- Comparison site:https://github.com/terrastruct/text-to-diagram-site
- Playground:https://github.com/terrastruct/d2-playground
- IDE (paid):https://d2studio.ai
- Language docs:https://github.com/terrastruct/d2-docs
- Hosted icons:https://icons.terrastruct.com
- Does D2 collect telemetry?
- No, D2 does not use an internet connection after installation, except to check forversion updates from Github periodically.
- Does D2 need a browser to run?
- No, D2 can run entirely server-side.
- What's coming in the next release?
- I have a question or need help.
- The best way to get help is to ask onD2 Discord
- I have a feature request, proposal, or bug report.
- Please open up a Github Issue.
- I have a private inquiry.
- Please reach out athi@d2lang.com.
Do you have or see an open-source project with.d2 files? Please submit a PR adding tothis selected list of featured projects using D2.
- ElasticSearch
- Sourcegraph
- Temporal
- Tauri
- Rust GUI framework (78.5k stars)
- Intellij
- Coder
- UCBerkeley
- Coronacheck
- Official app of the Netherlands for coronavirus entry passes.
- BlockProtocol
- The Block Protocol is an open standard for building and using data-driven blocks (1.2kstars).
- Dagger
- A programmable CI/CD engine that runs your pipelines in containers (8k stars).
- IvyWallet
- Open-source money manager app for Android (1.1k stars).
- LocalStack
- Cloud service emulator (46k stars)
- Queue Library
- Queue is a Golang library for spawning and managing a Goroutine pool
About
D2 is a modern diagram scripting language that turns text to diagrams.
Topics
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.


