Skip to main content

0.10.0

AI is ripping. Finally got around to clearing out some long-standing issues, formalize a grammar (though it's still wip), fix a bunch of corner cases, tedious issues, etc. I'm focusing on 2 things:

  1. Performance -- across size of build (mainly for client-side/JS use case), size of output, and speed. All 3 have advanced significantly in this release, somewhat near capabilities of public frontier models. We'll revisit when the Reimann Hypothesis-solving generation of models come out.
  2. Animations. I make a lot of 3b1b-type explainer videos to understand things in my day-to-day work and the quality is tempermental. There's a 3b1b library for their animations but it didn't work well for me and I've removed it from my prompts. I'm more motivated to do well here for my own use case, so I want to make animations in D2 really nice throughout the 0.10 series of releases.

I plan to cut a 1.0 soon finally. There'll be more one-time breaking changes like consolidating casing/hyphenation (e.g. sequence_diagram to sequence-diagram).

AI-generated changelog:

Features ๐Ÿš€โ€‹

  • Animated transitions. Set animate-duration to animate styles, gradients, text decorations, grid edits, and sketch shading in SVG or GIF. It defaults to zero. animate-interval sets the minimum time per board. Timing ยท Grid examples
A shield cache combines 1,200 requests from six edge locations into one origin read.

Cache stampede source

  • TALA step animations. Small edits can preserve node positions and routes across steps and scenarios. Connections draw in, groups move between containers, trailing SQL rows slide in or out, and sequence messages travel to their receivers. Animated steps and source ยท Go API
A telescope detects a signal. An outbox saves the receipt and reuses it when the publisher retries.
warning

Animated transitions are in alpha. Send feedback or suggestions.

  • Language server. Run d2 lsp for live diagnostics, completion, and formatting in your editor. Go to definition, find references, and rename shapes across open diagrams and their imports. In VS Code, install the official extension with code --install-extension d2lang.d2lang. VS Code guide ยท Other editors
  • MCP server. Run d2 mcp to let an AI client look up D2 syntax, check diagrams, and render PNG, SVG, or text. Starting with v0.10.0, stable releases publish io.github.d2lang/d2 to the official MCP Registry after the PyPI package ships. Set up Codex or Claude Code ยท Registry listing manifest
  • ELK. Set elk-algorithm in the diagram. New options control edge routing, layer placement, tree ordering, and spacing. Compare algorithms ยท Layered options ยท Run the radial example in the Playground
  • Configuration. Set scale and force-appendix in vars.d2-config, and dagre-nodesep and dagre-edgesep in vars.d2-config.data. Export options ยท Dagre spacing
  • Connections. Crossing lines now leave a transparent gap in the back line where thereโ€™s room. #3011
  • Themes. Select light and dark themes by name, for example theme-id: Terminal or --dark-theme dark-mauve. Themes
  • Syntax. Use unquoted labels like cost $5 and #oncall, colors like #abc, and names like R&D. Variables can use keyword names, and nested shapes can be named layers, scenarios, or steps. Punctuation ยท Hash-prefixed labels and keyword names
  • Formatter. d2 fmt README.md formats D2 fences in Markdown. Use d2 fmt --check --diff README.md to show a diff in CI. Formatter options
  • Installation. Run the CLI with uvx d2lang, or install it in CI with d2lang/setup-d2@v1. Windows x64 now has a -user.msi installer for users without administrator rights. uv and uvx ยท GitHub Actions ยท Windows
  • Linux packages. Install a specific GitHub release with APT on Debian or Ubuntu (amd64, arm64) or DNF on Fedora or RHEL (x86_64, aarch64). Download the matching .deb or .rpm and pass its local path to the package manager. Debian and Ubuntu ยท Fedora and RHEL
  • Language reference. Explore the grammar with railroad diagrams, EBNF, and parser conformance cases. Download the docs as Markdown, by page or in one file. Grammar reference ยท Conformance cases ยท Page index ยท Full text

Improvements ๐Ÿงนโ€‹

CLI export time on an Apple M4, including startup, layout, and SVG output. Timings use d70ec718.

Workloadv0.9.0v0.10.0 candidateSpeedup
3,000 rectangles in a grid8.29 s159 ms52.1ร—
Ten real-world diagrams, sum of medians451 ms307 ms1.47ร—

Layout and rendering. Native timings compare each optimization with its preceding implementation. Engine rows total layout time across the test suite. Layout benchmarks

WorkloadBeforeAfter
Dagre298 ms22.9 ms
ELK190 ms28.1 ms
TALA, one seed, including routing11.47 s3.08 s
Choose grid row breaks, 100 cells in 10 rows27.94 ms11.38 ยตs
Compile two SQL tables with a global edge style declared first936 ยตs73 ยตs
Re-render a 1,000-message sequence after a label edit24.4 ms16.3 ms
Write a 30-slide PowerPoint deck3.3 ms2.1 ms

SVG output size. Each file uses gzip level 9. The two candidate builds produced identical SVGs for all 16 fixtures with version metadata omitted. SVG changes

Diagramv0.9.0v0.10.0 candidateReduction
Links example with forced appendix274.6 KB117.8 KB57.1%
Five multiboard animations37.9 KB30.4 KB19.6%
Ten real-world diagrams200.8 KB198.9 KB1.0%

CLI and Docker sizes. The macOS candidate was built at e53d9644.

ArtifactBeforeAfterChange
Docker layers, Linux x86-64, before/after deduplication92.16 MB54.60 MBโˆ’41%
Docker layers, Linux arm64, same change86.55 MB52.16 MBโˆ’40%
macOS arm64 CLI, v0.9.0 โ†’ candidate40.04 MB39.28 MBโˆ’1.9%
Linux x86-64 CLI, PowerPoint writer change alone43.47 MB40.42 MBโˆ’7%
  • TALA aligns connections across containers, centers parallel branches, packs hierarchies more tightly, and routes larger diagrams. #3034 ยท #2986 ยท #3025
  • Grids balance row widths with grid-rows alone and column heights with grid-columns alone. Grid layouts
  • Exports. Repeated renders reuse bundled font measurements and subsets. Animated SVG connections respect prefers-reduced-motion. Multiboard exports preserve user edits, roll back on failure, and give reserved or nonportable board names hashed filenames. Links between boards follow the new paths. Font caching ยท #2976 ยท #2900
  • File and image access. Exports validate image contents and sizes. Use --allow-private-network for trusted internal images or --allow-local-files=false to disable local reads by diagrams. Go callers must set CompileOptions.FS to enable imports. Image access is configured separately. Go import options ยท Image options
  • Watch mode authenticates browser sessions through the URL printed by d2 --watch. #2910
  • Installation. Standalone installs verify SHA-256 checksums. Add --verify-provenance to verify signed builds locally. Source builds require Go 1.27.4 or newer. Go module installs report the installed D2 version in the CLI, LSP, and MCP server. Installer verification ยท Build from source

Bugfixes โ›‘๏ธโ€‹

  • CLI exports. Navigating the watch preview keeps the complete export on disk. Watch resolves Windows imports relative to their diagram. Links open boards with dotted names in SVG, PDF, and PowerPoint. The CLI preserves the source when input and output identify the same file. Text export honors source-selected TALA, and D2_STDOUT_FORMAT selects the format for stdout. #3076

  • Dagre. Containers keep the same dimensions across runs. Nested diagrams with connections between sibling containers can now render when Dagre previously failed during ordering or edge routing. Deterministic layouts ยท Nested diagrams

  • ELK. Force, stress, and Mr. Tree route labeled self-loops. These layouts and radial attach cross-container edges to the correct shape or SQL column. Loop labels clear rounded bends where space permits. Mr. Tree routes avoid crossing intervening nodes. #3016 ยท #3017 ยท #3018 ยท #2981

  • TALA. Fixed overlapping nodes and captions, reversed dependencies, and misplaced endpoint labels. Chains of step shapes retain connection order and annotations. Pinned junctions stay in place. SQL edges attach to the correct row, and routes stay attached when containers move. #3032 ยท #3022 ยท #3028 ยท #3031 ยท #2889

  • Grids. Grids with only grid-rows or grid-columns finish laying out even when one cell is much larger than the others. Cells keep their order through imports and variable spreads. Circles stay round, nested content fits, and routes retain SQL row targets and make room for self-loops. TALA routes around intervening cells and accepts grid containers as near targets. Grid connections ยท #3036

  • Sequence diagrams. A nested group containing only a note now renders. Notes after messages between spans on the same actor leave room for the preceding group. Sequence groups ยท #3035 ยท #2940

  • SVG. Stroke gradients continue through arrowheads. Link and tooltip numbering matches the appendix, including in animated frames. Board changes switch the drawing, links, and keyboard targets together. Scaled exports retain their size with footnotes. SVG text, attributes, links, paint values, and IDs are validated or escaped as appropriate. #3020 ยท #2962 ยท #2964 ยท #2919

  • Native exports. SVG icons render with gradients, masks, and blur. PDF backgrounds fill the margins on pages without navigation. PNG watch previews embed local images and show placeholders for missing images. #2982 ยท #2932 ยท #2980

  • Labels. SQL and class members retain types that match their names. Rounded tables and classes clip their contents to the outline. Fixed LaTeX font colors, paired delimiters, and bigtimes. ASCII fixes spacing for single-column multibyte characters such as Vietnamese letters and keeps arrowheads visible under long labels. SQL tables ยท UML classes ยท ASCII export

  • Syntax. Unquoted reserved keys ignore case. Quote "STYLE" for an object name. Labels like 10${unit} interpolate correctly. Undirected edges require --, block fences must match, and invalid groups, indices, filters, and paths report errors. d2 fmt preserves board order, import filename case, escapes, and empty maps. d2 fmt - writes already-formatted stdin to stdout. Formatter ยท Syntax fixes

  • Board globs. Globs apply once to each matching layer, scenario, or step, including imported boards. In a scenarios map, *.style.fill: red sets each scenarioโ€™s background. Use **.style.fill: red to fill its objects. Glob connections pair endpoints within the same board. Board glob fixes

  • Variables. Map spreads apply where they appear, so later assignments win. Templates keep their declaration scope and can style existing connections. Forward references resolve fully, glob filters see substituted values, and Markdown uses the nearest variable binding, including in link URLs and titles. Markdown variables ยท Variable fixes ยท Spread substitutions ยท #3044

  • Compiler and API. Parsing and compilation honor cancellation, including before d2 fmt writes. A step with a map can follow one without a map. Glob connections whose shared path matches nothing now compile, and invalid connection endpoints report errors. Cyclic variables, oversized expansions, invalid board trees, and oversized grids return errors. Go callers can configure expansion budgets. Each graph passed to Dagre or ELK is limited to 1,024 objects and 1,024 edges. LaTeX labels are limited to 4 KiB and 128 nested groups. Compiler and renderer limits

  • Windows and standalone installs. Nested imports resolve relative to the importing file, including on UNC shares. Git Bash can acquire the installer lock. Failed upgrades preserve the existing install. #2993 ยท #3026 ยท #3024

  • Formatter and Go editor. d2 fmt preserves names and labels split across lines. The Go editor distinguishes quoted shape names from properties and keeps label capitalization.

  • Dotted boards and arrays. Dotted steps and scenarios inherit shapes, connections, and rules. Array spreads preserve declaration order and later entries.

  • Selected imports. Imported values keep their module bindings and can use caller variables as fallbacks. Variables required only by unselected exports can be omitted.

  • Filters. Edge filters use each endpointโ€™s effective label and shape. Class filters accept lists and variables. Nesting depth is correct for shapes named root.

  • Animation and Markdown variables. Numeric variables with metadata interpolate across steps. Templates keep their declaration scope. Markdown substitutions preserve escaped placeholders, shortcut links, and variable names containing Markdown punctuation. #3063

Breaking Changesโ€‹

  • Quote shape names that match keywords. To keep a child named STYLE, change service.STYLE: notes to service."STYLE": notes and use api -> service."STYLE" in connections. Unquoted LABEL now sets a label, so an existing diagram can render differently even if it still compiles.
  • Check large generated diagrams. Dagre and ELK accept up to 1,024 objects and 1,024 edges per layout graph. A flat inventory of 1,025 independent services can use grid-columns: 32. For connected diagrams, split the drawing into boards.
  • Layout plugins and postprocessing. D2 no longer loads external d2plugin-* executables. Use a built-in engine. The Go packages d2plugin and d2layouts/d2layoutfeatures were removed. Drop the plugins argument when calling d2cli.LayoutResolver or d2cli.RouterResolver. To replace PostProcess, modify the bytes returned by d2svg.Render. Layout engines ยท Go example
  • Go struct changes. If you set ELK graph options directly, use EdgeEdgeSpacing (*int) for spacing between edges on adjacent layers. EdgeNode now takes a *float64. d2scenebuild.AssetOptions and d2themes.ThemableElement contain slice or map fields. Code that compares them with == or uses them as map keys must compare or key on the fields it needs.

D2.js 0.2.0โ€‹

The @d2lang/d2 package runs in browsers and Node.js.

  • Command line. Run npx @d2lang/d2 input.d2 output.svg to render a single file. Omit the output path to write an SVG beside the input, or pipe source to the command for SVG on stdout. After npm install @d2lang/d2, npm scripts can run d2-svg input.d2 output.svg. Use the native d2 CLI for PNG, PDF or local imports. CLI usage
  • API. d2.renderSVG() renders a D2 string or a multi-file project in one call. d2.format() formats a source file. TypeScript now covers theme overrides and the Playground helpers d2.encode() and d2.decode(). Decoded source is limited to 16 MiB. JavaScript API
  • Animations and fonts. Set animateDuration for step transitions. Use forceAppendix with animateInterval to show each boardโ€™s links and tooltips in its frame. Custom TrueType fonts supplied as Uint8Array now render correctly. Compiled diagrams retain their fonts when another diagram uses a different family or a saved diagram is rendered in a fresh worker. Animation options
  • Browser workers. Call new D2() inside a dedicated worker, or pass { workerURL } to load a self-hosted worker. Safari 27.2 workers start correctly. The SDK surfaces startup errors and releases the embedded worker URL after startup, including on failure. Worker options
  • Nightlies. Install the latest nightly with npm install @d2lang/d2@nightly.

Package size. Removing the goroutine scheduler and deduplicating fonts and tables cut the WebAssembly module by 53% compared with the preceding build. It still includes all three layout engines. All 24,824 outputs matched in the 519-script comparison. Building from source requires D2โ€™s TinyGo fork. Sizes were measured at e53d9644. Build instructions ยท Build changes and comparison

Artifact0.1.34 (npm)Before #30460.2.0 candidateReduction vs. 0.1.34
npm download31.66 MB13.65 MB8.28 MB73.8%
Unpacked npm package95.88 MB30.41 MB15.85 MB83.5%
WebAssembly, uncompressed42.12 MB22.49 MB10.59 MB74.8%
WebAssembly, Brotli-compressed inside browser module8.50 MB5.58 MB3.58 MB57.9%
Complete browser module, HTTP Brotli quality 58.52 MB5.64 MB3.65 MB57.1%

Chrome performance. Median times on an Apple M4 at d70ec718, with the browser module served from localhost. WebAssembly now decompresses in the worker, freeing the main thread during startup. The first SVG uses a fresh worker. The ten-diagram run reuses one worker for all ten compiles and renders. Benchmark diagrams

Workload0.1.34 (npm)Before #30460.2.0 candidateSpeedup vs. 0.1.34
First two-node SVG, including module download and import765 ms296 ms191 ms4.00ร—
First two-node SVG, after module import714 ms262 ms167 ms4.27ร—
Main-thread delay during startup (zero-delay timer)501 ms1.9 ms1.5 msโ€”
Ten real-world diagrams, warm worker748 ms310 ms208 ms3.59ร—

Install D2 ยท All changes since v0.9.0

Contents