Structurizr D2 Exporter
March 4, 2025 ยท View on GitHub
The D2Exporter class provides a way to export Structurizr views to diagram definitions that are compatible with D2.
This library is developed to be included in the Structurizr CLI, and is available on Maven Central, for inclusion in your own Java applications:
- groupId:
io.github.goto1134 - artifactId:
structurizr-d2-exporter

Table of Content
Customization
d2.title_position
- Entity:
views,view - Values:
top-left,top-center,top-right,center-left,center-right,bottom-left,bottom-center,bottom-right - Default:
top-center
Specifies diagram title position. For more details, see d2 near.
Example:
Source: title-position/workspace.dsl
bottom-left title:

d2.animation
- Entity:
views,view - Values:
d2,frames,no - Default:
d2
Specifies animation variant for animated structurizr views.
d2is for d2 steps animation that allows you to produce animated images.framesis for structurizr default frame animation. Unfortunately, it is not exportable yet.nocan be used in case you have animation steps, but do not want the animation.
Example:
d2.animated
- Entity:
relationshipstyle - Values:
true,false - Default:
false
Example
Source: animated-relation/workspace.dsl
Hint: Do not forget to provide --animate-interval flag when
producing SVG to see the animation.
d2.fill_pattern
- Entity:
views,view,elementstyle - Values:
dots,lines,grain - Default: โ
When set on views or view, adds a fill pattern to the background.
When set on an element style, adds fill pattern to its body.
Example
Source: fill-pattern/workspace.dsl

d2.use_c4_person (experimental)
- Entity:
views,view - Values:
true,false - Default:
false
Uses d2 c4_person shape for structurizr Person and Robot.
Hint:
- Verify if your d2 version supports
c4_person, see https://github.com/terrastruct/d2/pull/2397. - In structurizr
Personelements' default shape isBox. Use a custom style for aPersonshape:
views {
styles {
# structurizr uses retangle shapes for Person by default
element "Person" {
shape Person
}
}
}