# D2

[D2](https://d2lang.com/) snippets can be converted into images automatically for any snippets tagged with the `d2` 
language and using a `+render` attribute:

~~~markdown
```d2 +render
my_table: {
  shape: sql_table
  id: int {constraint: primary_key}
  last_updated: timestamp with time zone
}
```
~~~


**This requires having [d2](https://github.com/terrastruct/d2) installed**.

Similar to [mermaid diagrams support](mermaid.md), d2 diagrams:

* Will take some time because of how slow the d2 tool is.
* Can be scaled by using a `+width:<number>%` attribute in the snippet or by setting the `d2.scale` property in the 
config file, which is passed along to the `--scale` parameter to the d2 CLI.

## Theme

The theme of the rendered d2 diagrams can be changed through the `d2.theme` [theme](../themes/introduction.md) 
parameter. See the available themes in the [d2 docs](https://d2lang.com/tour/themes/).
