D2 Review (2026): Pricing, Features & Honest Verdict
TLDR
D2 is a modern, open-source diagram scripting language that produces clean, well-laid-out diagrams from declarative text. Best for: developers who want better auto-layout and theming than Mermaid offers. Price: completely free (open source). Rating: 7.4/10
What is D2?
D2 (Declarative Diagramming) is a diagram scripting language created by Terrastruct. You write structured text describing nodes, connections, and containers, and D2 compiles it into SVG diagrams with automatic layout. The project launched in late 2022 as a modern alternative to tools like Mermaid and PlantUML, with a focus on readable syntax, sophisticated layout algorithms, and built-in theming.
Where D2 differs from older text-to-diagram tools is its emphasis on layout quality. It ships with multiple layout engines (dagre, ELK, and TALA) that handle complex diagrams more gracefully than most competitors. The syntax is also notably cleaner. Instead of arrow-heavy notation, D2 uses a declarative approach where you define shapes and connections in a way that reads almost like pseudocode.
Key Features
Clean Declarative Syntax
D2’s syntax is one of its strongest selling points. Defining a connection is as simple as writing x -> y: label. Containers (groups of related nodes) use curly braces. Styling uses familiar CSS-like properties. The result is diagram source code that is readable even without rendering it. Compare a moderately complex flowchart in D2 versus Mermaid or PlantUML, and D2’s version is typically shorter and easier to parse at a glance.
Multiple Layout Engines
D2 supports three layout engines out of the box. Dagre is the default and works well for most diagrams. ELK (Eclipse Layout Kernel) handles larger, more complex graphs with better edge routing. TALA is Terrastruct’s proprietary engine available in the paid tier, optimized for the cleanest possible output. Having multiple engines means you can switch layouts to find the best visual result for a given diagram without rewriting any code.
Built-in Theming
D2 ships with over 30 built-in themes ranging from professional and minimal to playful sketch styles. Applying a theme is a single command-line flag. You can also define custom themes by overriding color palettes, fonts, and shape styles. The theming system is more polished than what Mermaid or PlantUML offer, producing diagrams that look good without manual tweaking.
Animations and Interactivity
D2 supports animated connections (pulsing lines, flowing dots) in SVG output, which is useful for showing data flow or request paths. It also supports tooltips and links on diagram elements. These interactive features set D2 apart from purely static diagram tools and make the output more engaging in web-based documentation.
CLI-First Workflow
D2 runs as a command-line tool. You write a .d2 file, run d2 input.d2 output.svg, and get your diagram. The CLI also includes a watch mode that re-renders on file save, giving you a live preview workflow. There is a VS Code extension with syntax highlighting and preview, and the CLI integrates easily into CI/CD pipelines for automated diagram generation.
Pricing Breakdown
D2 the language and CLI are completely free and open source under the MPL-2.0 license. All diagram types, two layout engines (dagre and ELK), all themes, and the VS Code extension are included at no cost. There are no usage limits or feature gates on the open-source tool.
Terrastruct, the company behind D2, offers TALA (their premium layout engine) and Terrastruct Cloud (a web-based collaborative editor) as paid products. TALA pricing is not publicly listed and requires contacting sales. For most individual developers and small teams, the free tier with dagre or ELK is more than sufficient.
| Plan | Price | Plan Features | Best For |
|---|---|---|---|
| Open Source | Free | All diagram types, dagre + ELK layout engines, 30+ themes, CLI, VS Code extension | Individual developers and small teams |
| TALA Engine | Contact sales | Premium layout engine with optimized routing and spacing | Teams needing the cleanest possible diagram output |
Who Should Use D2?
D2 is aimed at developers who care about diagram aesthetics and are willing to install a CLI tool to get better results. If you find Mermaid’s auto-layout frustrating on complex diagrams or want more theming options without manual CSS, D2 is a strong upgrade. It fits well into documentation-as-code workflows where diagrams are generated as part of a build pipeline.
Teams that rely heavily on GitHub’s native Mermaid rendering will find D2 harder to adopt, since D2 diagrams require a separate compilation step. If your primary use case is quick diagrams inside GitHub READMEs, Mermaid’s ecosystem advantage outweighs D2’s technical superiority. D2 shines when diagrams are compiled as part of a documentation build (using tools like Docusaurus, Hugo, or MkDocs).
Real-World Performance
In practice, D2 delivers on its core promise. The diagrams look noticeably better than Mermaid output, especially for sequence diagrams and complex flowcharts with many crossing edges. The ELK layout engine handles 50+ node diagrams without the overlapping and cramping issues that plague Mermaid. Themes make it easy to produce diagrams that match your documentation site’s visual style.
The trade-off is workflow friction. Every diagram requires running the D2 CLI or setting up a build step. There is no “paste syntax into a Markdown file and it renders” experience like Mermaid on GitHub. For teams that already have a documentation build pipeline, this is a minor inconvenience. For those who want zero-setup diagramming, it is a real barrier.
The community is growing but still small compared to Mermaid. Finding examples, troubleshooting syntax issues, and getting community support takes more effort. The documentation is well-written but covers fewer edge cases than Mermaid’s extensive wiki and community resources.
D2 vs. The Ecosystem
Against Mermaid, D2 produces better-looking diagrams with more reliable layouts. Mermaid wins on ecosystem reach, platform support, and community size. The choice often comes down to whether you need native rendering in GitHub/Notion (Mermaid) or the best possible diagram output (D2).
Against PlantUML, D2 offers a more modern syntax, better theming, and does not require Java. PlantUML has deeper UML support and decades of enterprise adoption. D2 is the better choice for new projects, while PlantUML may be hard to replace in organizations that have built extensive tooling around it.
Against Graphviz, D2 is essentially a modern successor. Graphviz’s DOT language inspired many text-to-diagram tools, but its output looks dated and the syntax is verbose. D2 produces cleaner output with less code and supports more diagram types.
Pros and Cons
What Works Well
The declarative syntax is genuinely readable and concise. Multiple layout engines give flexibility for different diagram complexities. Built-in themes produce professional-looking diagrams without manual styling. Animations and interactive elements add value for web documentation. The CLI is fast and integrates well into build pipelines.
What Could Be Better
No native rendering on GitHub, GitLab, Notion, or other major platforms. The community and ecosystem are significantly smaller than Mermaid’s. Requires CLI installation, which adds friction for quick diagrams. The TALA premium layout engine is closed-source and requires a paid license. Documentation, while good, has gaps for advanced use cases.
Alternatives
Mermaid
Mermaid is the most widely adopted text-to-diagram tool, with native rendering on GitHub, GitLab, Notion, and Obsidian. Its syntax is simple and the ecosystem is massive. Mermaid is the better choice when you want zero-friction diagram embedding in Markdown. D2 produces better-looking output, but Mermaid’s platform reach is unmatched.
PlantUML
PlantUML is the enterprise standard for text-based UML diagrams. It supports more UML-specific diagram types than either D2 or Mermaid and handles complex layouts reliably. The Java dependency and server-side rendering model are downsides, but for teams deeply invested in UML workflows, PlantUML remains the most complete option.
Graphviz
Graphviz is the original text-to-diagram tool, using the DOT language to describe graph structures. It is still widely used in academic and scientific contexts. The output is functional but visually dated compared to D2 or Mermaid. Graphviz is best for programmatic graph visualization where aesthetics are secondary to accuracy.
D2 Pros & Cons
What We Like
- Declarative syntax is clean, readable, and concise compared to competitors
- Multiple layout engines (dagre, ELK) handle complex diagrams well
- 30+ built-in themes produce professional diagrams without manual styling
- Supports animations and interactive elements in SVG output
- Fast CLI with watch mode for live preview during development
What Could Be Better
- No native rendering on GitHub, GitLab, Notion, or other major platforms
- Much smaller community and ecosystem compared to Mermaid
- Requires CLI installation, adding friction for quick one-off diagrams
- Premium TALA layout engine is closed-source and requires paid license
D2 FAQ
Is D2 free to use?
Yes. The D2 language, CLI, two layout engines (dagre and ELK), all themes, and the VS Code extension are free and open source under the MPL-2.0 license. The TALA premium layout engine and Terrastruct Cloud are paid products.
How does D2 compare to Mermaid?
D2 produces better-looking diagrams with more reliable layouts, especially for complex graphs. Mermaid has a much larger ecosystem and native rendering on GitHub, GitLab, and Notion. D2 requires a CLI compilation step while Mermaid renders directly in Markdown.
Can I use D2 in my CI/CD pipeline?
Yes. D2 is a CLI tool that takes .d2 files as input and outputs SVG, PNG, or PDF. You can add a build step to compile diagrams as part of your documentation pipeline using any CI/CD system.
What is D2?
Modern open-source diagram scripting language with declarative syntax, multiple layout engines, and built-in theming. Produces clean SVGs from text via CLI.
How much does D2 cost?
D2 pricing starts at Free (open source). A free plan is available.
Is D2 worth it?
D2 is a technically superior text-to-diagram tool that produces cleaner layouts and better-looking output than Mermaid. The declarative syntax is intuitive, the theming system is polished, and multiple layout engines handle complex diagrams well. The main limitation is ecosystem reach. Without native rendering on GitHub or Notion, D2 requires a build step that adds friction. For teams with documentation pipelines, D2 is an excellent choice. For quick README diagrams, Mermaid remains easier. We rate it 7.4/10.






