Skip to main content

Autoformat

Running d2 file.d2 reads the diagram source and writes file.svg.

Running the formatter​

Suppose file.d2 contains the following diagram.

Run d2 fmt file.d2 to rewrite the source with standard spacing and arrow syntax.

Some editor extensions can also run the formatter when you save a file.