14
14
d2 – compiles and renders d2 diagrams into svgs.
15
15
16
16
SYNOPSIS
17
- d2 [--watch false] [--theme 0] file.d2 [file.svg | file.png]
17
+ d2 [--watch false] [--theme 0] [--salt string] file.d2
18
+ [file.svg | file.png]
18
19
d2 layout [name]
19
20
d2 fmt file.d2 ...
21
+ d2 play file.d2
22
+ d2 validate file.d2
20
23
21
24
DESCRIPTION
22
25
d2 compiles and renders file.d2 to file.svg | file.png.
@@ -88,7 +91,7 @@ OPTIONS
88
91
--animate-interval 0
89
92
If given, multiple boards are packaged as 1 SVG which
90
93
transitions through each board at the interval (in
91
- milliseconds). Can only be used with SVG exports.
94
+ milliseconds). Can only be used with SVG and GIF exports.
92
95
93
96
--browser true
94
97
Browser executable that watch opens. Setting to 0 opens no
@@ -125,11 +128,30 @@ OPTIONS
125
128
out and exiting. When rendering a large diagram, it is
126
129
recommended to increase this value.
127
130
131
+ --check false
132
+ Check that the specified files are formatted correctly.
133
+
134
+ --salt string
135
+ Add a salt value to ensure the output uses unique IDs. This
136
+ is useful when generating multiple identical diagrams to be
137
+ included in the same HTML doc, so that duplicate id's do not
138
+ cause invalid HTML. The salt value is a string that will be
139
+ appended to IDs in the output..
140
+
128
141
-h, --help Print usage information and exit.
129
142
130
143
-v, --version
131
144
Print version information and exit.
132
145
146
+ --stdout-format string
147
+ Set the output format when writing to stdout. Supported
148
+ formats are: png, svg. Only used when output is set to stdout
149
+ (-).
150
+
151
+ --no-xml-tag false
152
+ Omit XML tag (<?xml ...?>) from output SVG files. Useful when
153
+ generating SVGs for direct HTML embedding.
154
+
133
155
SUBCOMMANDS
134
156
layout Lists available layout engine options with short help.
135
157
@@ -140,11 +162,88 @@ SUBCOMMANDS
140
162
themes Lists available themes.
141
163
142
164
fmt file.d2 ...
143
- Format all passed files.
165
+ Format all passed files
166
+
167
+ play file.d2
168
+ Opens the file in playground, an online web viewer
169
+ (https://play.d2lang.com)
170
+
171
+ validate file.d2
172
+ Validates file.d2
173
+
174
+ ENVIRONMENT VARIABLES
175
+ Many flags can also be set with environment variables.
176
+
177
+ D2_WATCH
178
+ See -w[atch] flag.
179
+
180
+ D2_LAYOUT
181
+ See -l[ayout] flag.
182
+
183
+ D2_THEME
184
+ See -t[heme] flag.
185
+
186
+ D2_DARK_THEME
187
+ See --dark-theme flag.
188
+
189
+ D2_PAD See --pad flag.
190
+
191
+ D2_CENTER
192
+ See --center flag.
193
+
194
+ D2_SKETCH
195
+ See -s[ketch] flag.
196
+
197
+ D2_BUNDLE
198
+ See -b[undle] flag.
199
+
200
+ D2_FORCE_APPENDIX
201
+ See --force-appendix flag.
202
+
203
+ D2_FONT_REGULAR
204
+ See --font-regular flag.
205
+
206
+ D2_FONT_ITALIC
207
+ See --font-italic flag.
208
+
209
+ D2_FONT_BOLD
210
+ See --font-bold flag.
211
+
212
+ D2_FONT_SEMIBOLD
213
+ See --font-semibold flag.
214
+
215
+ D2_ANIMATE_INTERVAL
216
+ See --animate-interval flag.
217
+
218
+ D2_TIMEOUT
219
+ See --timeout flag.
220
+
221
+ D2_CHECK
222
+ See --check flag.
223
+
224
+ DEBUG See -d[ebug] flag.
225
+
226
+ IMG_CACHE
227
+ See --img-cache flag.
228
+
229
+ HOST See -h[ost] flag.
230
+
231
+ PORT See -p[ort] flag.
232
+
233
+ BROWSER
234
+ See --browser flag.
235
+
236
+ D2_STDOUT_FORMAT
237
+ See --stdout-format flag.
238
+
239
+ D2_NO_XML_TAG
240
+ See --no-xml-tag flag.
144
241
145
242
SEE ALSO
146
243
d2plugin-tala(1)
147
244
148
245
AUTHORS
149
246
Terrastruct Inc.
247
+
248
+ macOS 14.1 March 12, 2025 macOS 14.1
150
249
```
0 commit comments