# terrastruct/d2

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/terrastruct-d2).**

23,083 stars · 616 forks · Go · mpl-2.0

## Links

- GitHub: https://github.com/terrastruct/d2
- Homepage: https://d2lang.com
- awesome-repositories: https://awesome-repositories.com/repository/terrastruct-d2.md

## Topics

`developer-tools` `diagramming` `diagrams` `go` `golang` `software-architecture` `text-to-diagram`

## Description

This project is a diagram-as-code tool that transforms declarative text scripts into professional visual representations. It functions as a technical documentation generator, allowing users to define nodes, connections, and hierarchical relationships through a domain-specific modeling language that integrates directly into version-controlled developer workflows.

The tool distinguishes itself through a highly modular architecture that decouples diagram definitions from spatial positioning. It features a pluggable layout engine that supports multiple arrangement algorithms, alongside a styling system inspired by web development that enables global theme management and reusable class-based properties. Users can further customize their output with a sketch-like aesthetic, interactive metadata, and the ability to embed rich content such as markdown and code snippets directly into diagrams.

Beyond basic rendering, the system provides comprehensive support for large-scale documentation projects through file modularization, content parameterization, and automated code formatting. It includes a reactive file watcher for live updates and supports a wide range of output formats, including vector graphics, raster images, and terminal-based text diagrams. The tool also facilitates the creation of interactive presentations and sequential animations to illustrate complex technical workflows.

The software is distributed as a command-line utility designed for integration into automated build pipelines and development environments.

## Tags

### Software Engineering & Architecture

- [Text-to-Diagram Generators](https://awesome-repositories.com/f/software-engineering-architecture/software-architecture/diagramming-standards/text-to-diagram-generators.md) — Transforms structured text descriptions into visual diagrams by interpreting declarative syntax. ([source](https://cdn.jsdelivr.net/gh/terrastruct/d2@master/README.md))
- [Graph Layout Engines](https://awesome-repositories.com/f/software-engineering-architecture/software-architecture/diagramming-standards/graph-layout-engines.md) — Supports pluggable layout engines that decouple diagram definitions from spatial positioning logic.
- [Software Architecture](https://awesome-repositories.com/f/software-engineering-architecture/software-architecture.md) — Provides specialized syntax for creating hierarchical system diagrams to visualize software structures. ([source](https://d2lang.com/blog/))
- [Plugin Architectures](https://awesome-repositories.com/f/software-engineering-architecture/integration-extensibility/extensibility/plugin-architectures.md) — Supports a plugin architecture to extend core functionality by connecting to external editors and data sources. ([source](https://cdn.jsdelivr.net/gh/terrastruct/d2@master/README.md))
- [Diagramming Standards](https://awesome-repositories.com/f/software-engineering-architecture/software-architecture/diagramming-standards.md) — Supports standard notations like class and sequence diagrams for accurate technical system representation. ([source](https://d2lang.com/))
- [Modularization Utilities](https://awesome-repositories.com/f/software-engineering-architecture/software-architecture/diagramming-standards/text-to-diagram-generators/modularization-utilities.md) — Facilitates large-scale documentation projects by allowing file imports and variable usage. ([source](https://d2lang.com))

### Development Tools & Productivity

- [Command Line Interfaces](https://awesome-repositories.com/f/development-tools-productivity/command-line-interfaces.md) — Provides a command-line interface for executing tasks, integrating with build pipelines, and supporting developer workflows. ([source](https://d2lang.com/))
- [Technical Documentation](https://awesome-repositories.com/f/development-tools-productivity/technical-documentation.md) — Generates professional visual diagrams from structured text scripts to document system architectures.
- [Version-Controlled Documentation](https://awesome-repositories.com/f/development-tools-productivity/version-controlled-documentation.md) — Manages visual documentation as version-controlled text files to ensure consistency across teams.
- [Diagramming Language Tooling](https://awesome-repositories.com/f/development-tools-productivity/language-support-extensions/diagramming-language-tooling.md) — Offers syntax highlighting, automatic formatting, and real-time error reporting to improve productivity during diagram creation. ([source](https://cdn.jsdelivr.net/gh/terrastruct/d2@master/README.md))

### Content Management & Publishing

- [Documentation Generators](https://awesome-repositories.com/f/content-management-publishing/content-management-systems/content-architecture-modeling/documentation-tooling/generation-publishing/documentation-generators.md) — Creates software architecture models and system maps from version-controlled text files.
- [Diagram Exporting](https://awesome-repositories.com/f/content-management-publishing/content-formats-exporting/diagram-exporting.md) — Supports export to various standard image and document formats for publishing compatibility. ([source](https://cdn.jsdelivr.net/gh/terrastruct/d2@master/README.md))

### Graphics & Multimedia

- [Diagramming Engines](https://awesome-repositories.com/f/graphics-multimedia/visualization-mapping/diagramming-engines.md) — Renders visual diagrams from structured text files using a domain-specific language. ([source](https://play.d2lang.com/))
- [Multi-Format Output Renderers](https://awesome-repositories.com/f/graphics-multimedia/graphics-engines-rendering/rendering/systems/multi-format-output-renderers.md) — Translates internal graph models into diverse output formats including vector graphics, raster images, and text diagrams.
- [Automatic Diagram Renderers](https://awesome-repositories.com/f/graphics-multimedia/visualization-mapping/visualization-frameworks/automatic-diagram-renderers.md) — Converts structured text definitions into plain text visual representations for terminal viewing. ([source](https://d2lang.com/blog/))
- [Interactive Diagramming Libraries](https://awesome-repositories.com/f/graphics-multimedia/visualization-mapping/visualization-frameworks/interactive-diagramming-libraries.md) — Enables embedding of interactive metadata like tooltips and hyperlinks within complex diagrams. ([source](https://play.d2lang.com/))

### Data & Databases

- [Declarative Visualization Languages](https://awesome-repositories.com/f/data-databases/data-analysis-visualization/visualization-frameworks-libraries/declarative-visualization-languages.md) — Provides a domain-specific language for defining nodes and connections that render into interactive visual representations.
- [Intermediate Representations](https://awesome-repositories.com/f/data-databases/data-processing-pipelines/data-processing-frameworks/intermediate-representations.md) — Normalizes input scripts into a unified intermediate graph representation to facilitate consistent cross-format rendering.
- [Graph Layout Engines](https://awesome-repositories.com/f/data-databases/graph-layout-engines.md) — Allows users to switch between different layout algorithms to optimize node and link positioning. ([source](https://cdn.jsdelivr.net/gh/terrastruct/d2@master/README.md))

### Programming Languages & Runtimes

- [Domain Specific Languages](https://awesome-repositories.com/f/programming-languages-runtimes/programming-language-varieties/domain-specific-languages.md) — Uses a specialized domain-specific language to define nodes, edges, and hierarchical relationships for diagram generation.

### Education & Learning Resources

- [Technical Presentation Tools](https://awesome-repositories.com/f/education-learning-resources/technical-presentation-tools.md) — Compiles text-based diagram definitions into interactive slide decks for technical presentations.

### User Interface & Experience

- [Content Embedding Tools](https://awesome-repositories.com/f/user-interface-experience/content-embedding-tools.md) — Supports embedding rich content like markdown, code snippets, and images directly into diagram layouts. ([source](https://d2lang.com))
- [CSS Class-Based Styling](https://awesome-repositories.com/f/user-interface-experience/styling-theming-systems/content-styling/styling-architectures/styling-systems/class-based-styling/css-class-based-styling.md) — Provides a CSS-inspired class-based system for managing global themes and reusable visual properties in diagrams.
