---
title: D2
description: D2 diagrams via Kroki; minimal snippet, rendered example, and generate_uml parameters.
tags:
  - reference
  - diagrams
---

# D2

[D2](https://d2lang.com/) is a declarative diagram language with first-class layout engines. UML-MCP renders D2 through Kroki using the same `generate_uml` tool as other types; set `diagram_type` to `d2` and pass D2 source in `code`.

## Example (source)

```d2
service.frontend -> service.api: HTTP
service.api -> db: SQL
service.api -> cache: get/set
```

## Example (rendered SVG)

The SVG below was produced with `generate_uml` (`diagram_type: d2`, `output_format: svg`) against the snippet above, then committed under `docs/assets/diagrams/`.

![D2 service architecture example](../assets/diagrams/d2-service-arch.svg)

## Parameters

| Property | Value |
| --- | --- |
| `diagram_type` | `d2` |
| Backend | D2 (via Kroki) |
| Output formats | `svg` |

## See also

- [Graphviz](graphviz.md) for DOT graphs
- [More diagram backends](general.md) (hub: ERD, DBML, BlockDiag, BPMN, C4, Structurizr, specialty)
- [Diagram catalog](index.md) for the full `diagram_type` list
