d2(1)

NAME
d2 - compiles and renders d2 diagrams into svgs.

SYNOPSIS
d2 [--watch false] [--theme 0] file.d2 [file.svg | file.png]
d2 layout [name]
d2 fmt file.d2 ...

DESCRIPTION
d2 compiles and renders file.d2 to file.svg | file.png.

It defaults to file.svg if no output path is passed.

Pass - to have d2 read from stdin or write to stdout.

Never use the presence of the output file to check for success. Always use the exit status of d2. This is because sometimes when errors occur while rendering, d2 still write out a partial render anyway to enable iteration on a broken diagram.

See more docs, the source code and license at https://oss.terrastruct.com/d2.

Hosted icons at https://icons.terrastruct.com.

Playground runner at https://play.d2lang.com.

OPTIONS

-w, --watch false
    Watch for changes to input and live reload. Use $PORT and $HOST to specify the listening address.

-h, --host localhost
    Host listening address when used with watch.

-p, --port 0
    Port listening address when used with watch.

-t, --theme 0
    Set the diagram theme ID.

-s, --sketch false
    Renders the diagram to look like it was sketched by hand.

--pad 100
    Pixels padded around the rendered diagram.

-l, --layout dagre
    Set the diagram layout engine to the passed string. For a list of available options, run layout.

-b, --bundle true
    Bundle all assets and layers into the output svg.

--force-appendix 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.

-d, --debug
    Print debug logs.

-h, --help
    Print usage information and exit.

-v, --version
    Print version information and exit.

SUBCOMMANDS

layout
    Lists available layout engine options with short help.

layout [name]
    Display long help for a particular layout engine, including its configuration options.

themes
    Lists available themes.

fmt file.d2 ...
    Format all passed files.

SEE ALSO
d2plugin-tala(1)

AUTHORS
Terrastruct Inc.