D2
D2 is a modern, open-source diagram scripting language that enables users to define diagrams using a simple, readable text syntax. It is designed to be easy to learn while providing the power to create professional-quality diagrams for software architecture, network topology, flowcharts, and more. D2 compiles text into SVG or PNG images, making it suitable for both interactive viewing and static export. The language emphasizes clarity and expressiveness, with features like automatic layout, themes, and support for complex nested structures. D2 is written in Go and is distributed as a single binary, making it lightweight and easy to install across platforms. It also includes a language server protocol (LSP) implementation for editor integration. D2 is open source and community-driven, hosted on GitHub under the Terrastruct organization. It aims to provide a better alternative to existing tools by offering a balance of simplicity, performance, and visual quality. The project is actively maintained and has gained popularity among developers for creating diagrams as code.
- Category
- Dev Tools
- Pricing
- Open Source
Problem solved
Creating diagrams manually with drag-and-drop tools is time-consuming and difficult to version control. D2 solves this by allowing users to define diagrams as code, enabling automation, reuse, and consistency across documentation and system designs.
Use cases
- Software architecture diagrams
- Network topology diagrams
- Flowcharts and process diagrams
- Sequence diagrams
- Infrastructure-as-code documentation
- Automated diagram generation in CI/CD pipelines
Audience
- Developers
- Enterprise
- Startups
- ML Engineers
- Data Scientists
Pros
- Simple, declarative syntax
- Fast and lightweight binary
- High-quality default themes and layouts
- Supports SVG and PNG export
- Active open-source community
Cons
- Limited to diagram types supported by the language
- No built-in graphical editor (text-only)
- Younger ecosystem compared to mature tools
- May require learning new syntax for advanced features
Official website: https://github.com/terrastruct/d2
Canonical LambdaBase page: https://www.lambdabase.com/tools/d2