Convert D2 to PNG

Turn D2 files into PNG. The main board laid out in the default theme at twice its natural size, drawn without a browser in the fonts d2 embeds; 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

Your D2 diagram as a PNG image.The main board, drawn at twice its natural size.

  1. What you get

    One PNG of the main board of your diagram. It is laid out in the default theme and drawn at twice its natural size. PNG is a lossless format with an alpha channel, which suits graphics with sharp edges.

    The diagram is drawn without a browser, in the fonts d2 embeds. The text in the image uses those fonts.

  2. What it leaves behind

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

  3. When it fails

    If the D2 file cannot be parsed, the conversion stops with input_corrupted. Fix the D2 code so it parses, then convert it again.

    There are no options to set. Every conversion uses the same theme and size.

D2 and PNG.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 · PNG

PNG

Lossless raster images with an alpha channel. Screenshots, icons and graphics with sharp edges.

Extensions
.png
MIME type
image/png
Kind
Images

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

terminal
$ cv convert report.d2 report.png
$ cv convert report.d2 report.png

Questions.What people ask about D2 to PNG.

01OF 04

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

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

The file could not be parsed. The conversion stops there and produces no image.

One file. It is a single PNG of the main board.

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