d2(1)
d2(1) π
okay so this is the General Commands Manual page for d2(1) β yes, the diagram compiler β and we're gonna get you comfy with it, bestie. β¨
π NAME π
d2 β compiles and renders d2 diagrams into svgs.
β¨ SYNOPSIS β¨
d2 [--watch false] [--theme 0] [--salt string] file.d2
[file.svg | file.png | file.pdf | file.pptx | file.gif | file.txt]
d2 layout [name]
d2 fmt file.d2 ...
d2 play file.d2
d2 validate file.d2
πΈ DESCRIPTION πΈ
d2 compiles and renders file.d2 to file.svg | file.png | file.pdf | file.pptx | file.gif | file.txt.
It defaults to file.svg if no output path is passed. π«Ά
Pass - to have d2 read from stdin or write to stdout.
PNG exports support up to 32768 pixels per dimension, subject to rendering resource limits.
bestie, listen: never use the presence of the output file to check for success. Always use the exit status ofd2. This is because sometimes when errors occur while rendering,d2still write out a partial render anyway to enable iteration on a broken diagram. So yeah β exit status is the main character here. π
See more docs, the source code and license at https://github.com/d2lang/d2.
Hosted icons at https://icons.d2lang.com.
Playground runner at https://play.d2lang.com.
π OPTIONS π
-w,--watch falseβ watch for changes to input and live reload. Use$PORTand$HOSTto specify the listening address.-h,--host localhostβ host listening address when used withwatch.-p,--port 0β port listening address when used withwatch.-t,--theme 0β set the diagram theme ID.--dark-theme -1β the theme to use when the viewer's browser is in dark mode. When left unset,--themeis used for both light and dark mode. Be aware that explicit styles set in D2 code will still be applied and this may produce unexpected results. We plan on resolving this by making style maps in D2 light/dark mode specific. Seehttps://github.com/d2lang/d2/issues/831.-s,--sketch falseβ renders the diagram to look like it was sketched by hand.--center flagβ center the SVG in the containing viewbox, such as your browser screen.--scale -1β scale the output. E.g.,0.5to halve the default size. Default-1means that SVG's will fit to screen and all others will use their default render size. Setting to1turns off SVG fitting to screen.--font-regularβ path to.ttffile to use for the regular font. If none provided, Source Sans Pro Regular is used.--font-italicβ path to.ttffile to use for the italic font. If none provided, Source Sans Pro Regular-Italic is used.--font-boldβ path to.ttffile to use for the bold font. If none provided, Source Sans Pro Bold is used.--font-semiboldβ path to.ttffile to use for the semibold font. If none provided, Source Sans Pro Semibold is used.--font-monoβ path to.ttffile to use for the monospace font. If none provided, Source Code Pro Regular is used.--font-mono-boldβ path to.ttffile to use for the monospace bold font. If none provided, Source Code Pro Bold is used.--font-mono-italicβ path to.ttffile to use for the monospace italic font. If none provided, Source Code Pro Italic is used.--font-mono-semiboldβ path to.ttffile to use for the monospace semibold font. If none provided, Source Code Pro Semibold is used.--pad 100β pixels padded around the rendered diagram.--animate-interval 0β if given, multiple boards are packaged as 1 SVG which transitions through each board at the interval (in milliseconds). Can only be used with SVG or GIF exports. For GIF exports, defaults to1000msif not specified.--browser trueβ browser executable thatwatchopens. Setting to0opens no browser.-l,--layout dagreβ set the diagram layout engine to the passed string. For a list of available options, runlayout.-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 totrueadds an appendix to SVG exports as well.--targetβ target board to render. Pass an empty string to target root board. If target ends with'*', it will be rendered with all of its scenarios, steps, and layers. Otherwise, only the target board will be rendered. E.g.--target=''to render root board only or--target='layers.x.*'to render layer'x'with all of its children.-d,--debugβ print debug logs.--img-cache trueβ in watch mode, images used in icons are cached for subsequent compilations. This should be disabled if images might change.--timeout 120β the maximum number of seconds that D2 runs for before timing out and exiting. When rendering a large diagram, it is recommended to increase this value.--check falseβ check that the specified files are formatted correctly.--salt stringβ add a salt value to ensure the output uses unique IDs. This is useful when generating multiple identical diagrams to be included in the same HTML doc, so that duplicate id's do not cause invalid HTML. The salt value is a string that will be appended to IDs in the output.-h,--helpβ print usage information and exit.-v,--versionβ print version information and exit.--stdout-format stringβ set the output format when writing to stdout. Supported formats are:png,svg,ascii,txt,pdf,pptx,gif. Only used when output is set to stdout (-).--no-xml-tag falseβ omit XML tag (<?xml ...?>) from output SVG files. Useful when generating SVGs for direct HTML embedding.--omit-version falseβ omit D2 version from generated image.--ascii-mode extendedβ ASCII rendering mode for text outputs. Options:'standard'(basic ASCII chars) or'extended'(Unicode chars).
π¦ 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.play file.d2β opens the file in playground, an online web viewer (https://play.d2lang.com).validate file.d2β validatesfile.d2.
π ENVIRONMENT VARIABLES π
Many flags can also be set with environment variables. iykyk. π
D2_WATCHβ see-w[atch]flag.D2_LAYOUTβ see-l[ayout]flag.D2_THEMEβ see-t[heme]flag.D2_DARK_THEMEβ see--dark-themeflag.D2_PADβ see--padflag.D2_CENTERβ see--centerflag.D2_SKETCHβ see-s[ketch]flag.D2_BUNDLEβ see-b[undle]flag.D2_FORCE_APPENDIXβ see--force-appendixflag.D2_FONT_REGULARβ see--font-regularflag.D2_FONT_ITALICβ see--font-italicflag.D2_FONT_BOLDβ see--font-boldflag.D2_FONT_SEMIBOLDβ see--font-semiboldflag.D2_FONT_MONOβ see--font-monoflag.D2_FONT_MONO_BOLDβ see--font-mono-boldflag.D2_FONT_MONO_ITALICβ see--font-mono-italicflag.D2_FONT_MONO_SEMIBOLDβ see--font-mono-semiboldflag.D2_ANIMATE_INTERVALβ see--animate-intervalflag.D2_TIMEOUTβ see--timeoutflag.D2_CHECKβ see--checkflag.D2_ASCII_MODEβ see--ascii-modeflag.DEBUGβ see-d[ebug]flag.IMG_CACHEβ see--img-cacheflag.HOSTβ see-h[ost]flag.PORTβ see-p[ort]flag.BROWSERβ see--browserflag.D2_STDOUT_FORMATβ see--stdout-formatflag.D2_NO_XML_TAGβ see--no-xml-tagflag.OMIT_VERSIONβ see--omit-version.
π AUTHORS π
D2 contributors β iconic behavior, honestly. π
okay bye bestie β this page is from Debian, dated $Mdocdate$, and it's the d2(1) manual. periodt. π
π¦ where this page comes from
- arch rolling: d2 0.9.0-1 Β· MPL-2.0
- nixpkgs unstable: d2 0.9.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms