Convert D2 to SVG

Turn D2 files into SVG. The main board laid out in the default theme with its fonts embedded; layers, scenarios and steps are left out.

Converted in an isolated sandbox on our serversDeleted after 24 hours

Drop D2 files on the dialor turn it to pick what to do

A D2 diagram as one SVG file.The main board is laid out and drawn with its fonts embedded.

  1. What you get

    One SVG file of the main board. The boxes, arrows and containers from your D2 code are laid out in the default theme.

    The fonts are embedded in the file, so the text is drawn with the fonts it was laid out with.

  2. What it leaves behind

    Layers, scenarios and steps are left out. Only the main board is drawn, so anything you defined in those parts does not appear in the SVG.

    The default theme is used. The conversion has no options to change it.

  3. When it fails

    A file that cannot be parsed stops with input_corrupted. This means the D2 file could not be parsed.

    For other conversions, see every D2 conversion or every SVG conversion.

D2 and SVG.What each format is.

The formats

From · D2

D2 Diagram

Diagram code in the D2 language: boxes, arrows and containers.

Extensions
.d2
MIME type
text/x-d2
Kind
Text and data
To · SVG

SVG

Scalable vector graphics in XML. Logos, icons and diagrams that stay sharp at any size.

Extensions
.svg .svgz
MIME type
image/svg+xml
Kind
Images

In your code.The same D2 to SVG conversion through the API, for your app or your agent.

terminal
$ cv convert report.d2 report.svg
$ cv convert report.d2 report.svg

Questions.What people ask about D2 to SVG.

01OF 04

No. Layers, scenarios and steps are left out. Only the main board is in the SVG.

No. The diagram is laid out in the default theme, and there are no options to change it.

Yes. The fonts are embedded in the SVG file.

The file could not be parsed. The conversion stops with input_corrupted in that case.

More conversions.Other ways in and out of D2 and SVG.