.Dd $Mdocdate$ .Dt d2 1 .Os .Sh NAME .Nm d2 .Nd compiles and renders d2 diagrams into svgs. .Sh SYNOPSIS .Nm d2 .Op Fl -watch Ar false .Op Fl -theme Em 0 .Ar file.d2 .Op Ar file.svg | file.png .Nm d2 .Ar layout Op Ar name .Nm d2 .Ar fmt Ar file.d2 ... .Sh DESCRIPTION .Nm compiles and renders .Ar file.d2 to .Ar file.svg | .Ar file.png .Ns . .Pp It defaults to .Ar file.svg if no output path is passed. .Pp Pass - to have .Nm read from stdin or write to stdout. .Pp Never use the presence of the output file to check for success. Always use the exit status of .Nm d2 .Ns . This is because sometimes when errors occur while rendering, d2 still write out a partial render anyway to enable iteration on a broken diagram. .Pp See more docs, the source code and license at .Lk https://oss.terrastruct.com/d2 .Ns . .Pp Hosted icons at .Lk https://icons.terrastruct.com .Ns . .Pp Playground runner at .Lk https://play.d2lang.com .Ns . .Sh OPTIONS .Bl -tag -width Fl .It Fl w , -watch Ar false Watch for changes to input and live reload. Use .Ev $PORT and Ev $HOST to specify the listening address. .It Fl h , -host Ar localhost Host listening address when used with .Ar watch .Ns . .It Fl p , -port Ar 0 Port listening address when used with .Ar watch .Ns . .It Fl t , -theme Ar 0 Set the diagram theme ID .Ns . .It Fl t , -dark-theme Ar 0 the diagram dark theme ID. When left unset only the theme will be applied .Ns . .It Fl s , -sketch Ar false Renders the diagram to look like it was sketched by hand .Ns . .It Fl -pad Ar 100 Pixels padded around the rendered diagram .Ns . .It Fl l , -layout Ar dagre Set the diagram layout engine to the passed string. For a list of available options, run .Ar layout .Ns . .It Fl b , -bundle Ar true Bundle all assets and layers into the output svg. .It Fl -force-appendix Ar false An appendix for tooltips and links is added to PNG exports since they are not interactive. Setting this to true adds an appendix to SVG exports as well .Ns . .It Fl d , -debug Print debug logs. .It Fl h , -help Print usage information and exit. .It Fl v , -version Print version information and exit. .El .Sh SUBCOMMANDS .Bl -tag -width Fl .It Ar layout Lists available layout engine options with short help. .It Ar layout Op Ar name Display long help for a particular layout engine, including its configuration options. .It Ar themes Lists available themes. .It Ar fmt Ar file.d2 ... Format all passed files. .El .Sh SEE ALSO .Xr d2plugin-tala 1 .Sh AUTHORS Terrastruct Inc.