d2

D2 is a modern diagram scripting language that turns text to diagrams.

What is d2?

D2 is a modern diagram scripting language that turns text to diagrams.

Overview of d2

What it is

D2 is a modern diagram scripting language that turns text to diagrams. It is open-sourced under the Mozilla Public License 2.0. The project is categorized under Developer Tools. Its repository is at https://github.com/d2lang/d2 and its homepage is at https://d2lang.com. D2 can be used as a CLI executable to produce SVGs from .d2 files, and also as a library from Go programs. It supports SVG, PNG, GIF, PDF, and PPTX exports. D2 bundles three layout engines: Dagre (default), elk-go, and TALA. It also includes a variety of official themes and ships with the font Source Sans Pro. Language tooling includes a parser that can parse multiple errors, an autoformatter, and syntax highlighting. Extensions for VSCode and Vim are available. D2 also handles specialized layouts such as sequence diagrams and grids. Sketch-mode rendering uses rough-go, and LaTeX labels use mathjax-go. For a comparison against other text-to-diagram tools, see https://text-to-diagram.com.

Key features

  • Turns text to diagrams using a scripting language.
  • Supports export to SVG, PNG, GIF, PDF, and PPTX.
  • Bundles three layout engines: Dagre (default), elk-go, and TALA.
  • Includes official themes and the Source Sans Pro font.
  • Provides language tooling: parser with multiple error support, autoformatter, syntax highlighting.
  • Can be used as a CLI tool or as a Go library.
  • Handles specialized layouts like sequence diagrams and grids.

Use cases

  • Creating software architecture diagrams.
  • Generating network diagrams.
  • Producing sequence diagrams.
  • Building diagrams for documentation or presentations.
  • Integrating diagram generation into Go programs.

Getting started

sh # First, install D2 curl -fsSL https://d2lang.com/install.sh | sh -s -- echo 'x -> y -> z' > in.d2 d2 --watch in.d2 out.svg A browser window will open with out.svg and live-reload on changes to in.d2. Alternatively, if you have Go installed: sh go install github.com/d2lang/d2@latest For detailed installation docs, see the repository's INSTALL.md.

License and pricing

Licensed under the Mozilla Public License 2.0. It is open source and free to use.

Based on the project's public README and repository metadata.

Add this badge to your README

Featured on YunoDB Badge styles & help

Maintain this project? Show that it is featured on YunoDB.

Markdown[![Featured on YunoDB](https://yunodb.com/badge/d2langd2.svg)](https://yunodb.com/tools/d2langd2?utm_source=github&utm_medium=badge)
HTML<a href="https://yunodb.com/tools/d2langd2?utm_source=github&utm_medium=badge"><img src="https://yunodb.com/badge/d2langd2.svg" alt="Featured on YunoDB" height="20"></a>