# D2 Modern Diagram Scripting Language and CLI

> D2 is a modern diagram scripting language that turns text into diagrams. It compiles declarative text files into SVG, PNG, and PDF outputs with automatic layout, multiple themes, and support for sequence diagrams, class diagrams, and network topologies.

- Skill: `agentskillexchange/d2-modern-diagram-scripting-language-and-cli` (Agent Skill)
- Install (CLI): `npx skillmds@latest add agentskillexchange/d2-modern-diagram-scripting-language-and-cli`
- Raw SKILL.md: https://api.skillmd.com/api/skills/agentskillexchange/d2-modern-diagram-scripting-language-and-cli/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Docs & Writing
- Author: agentskillexchange (https://skillmd.com/u/agentskillexchange)
- Updated: 2026-09-08
- Page: https://skillmd.com/skills/agentskillexchange/d2-modern-diagram-scripting-language-and-cli

---


# D2 Modern Diagram Scripting Language and CLI

D2 is a modern diagram scripting language that turns text into diagrams. It compiles declarative text files into SVG, PNG, and PDF outputs with automatic layout, multiple themes, and support for sequence diagrams, class diagrams, and network topologies.

## Installation

Use the upstream install or setup path that matches your environment:
- go install oss.terrastruct.com/d2@latest

Requirements and caveats from upstream:
- particularly suited for node-link diagrams with an inherent direction and ports.
- specifically for software architecture diagrams. Requires separate install, visit the
- **Python D2 diagram builder**: [https://github.com/MrBlenny/py-d2](https://github.com/MrBlenny/py-d2)

Basic usage or getting-started notes:
- <img width="400px" src="./docs/assets/example.svg" alt="D2 render example" />
- The most convenient way to use D2 is to just run it as a CLI executable to
- produce SVGs from .d2 files.

- Source: https://github.com/terrastruct/d2
- Extracted from upstream docs: https://raw.githubusercontent.com/terrastruct/d2/HEAD/README.md

## Source

- [Agent Skill Exchange](https://agentskillexchange.com/skills/d2-diagram-scripting-language-cli/)

