Skip to main content

0.10.1

D2 adds annotations, animated scenarios, connection icons, linked-layer zooms, video export, sequence diagrams v2, TALA hierarchy layouts, image shape fitting, composite primary keys, source validation warnings, and hyphenated shape and SQL constraint names.

Features ๐Ÿš€โ€‹

  • Annotations. Draw marks (circle, box, underline, brace, cross, highlight, arrow, trace, or lasso) and Markdown notes over a shape or connection without changing its layout. Root annotation draws a board caption whose Markdown links cue shapes in caption order. Customize colors with annotation.style.stroke and annotation.style.font-color. Annotation guide
Nine annotation marks in a 3 by 3 grid: circle, box, underline, brace, cross, highlight, arrow, trace, and lasso.

Edit the annotation gallery in Playground

  • Animated scenarios and connection icons. Set animate-interval and animate-duration to tween directly between independent scenarios, and set icon.style.animated (e.g. 2/s or 200ms) with icon.shape (circle, square, triangle, diamond, or an icon image) to send traffic along connections. When an Atlas subscriber goes down, 120 events pile up; replay clears the backlog while live delivery resumes. Animation guide ยท Order-outbox example
Three Atlas delivery states show a working webhook, an outage with 120 queued events, and replay clearing the backlog.

Edit Atlas delivery in Playground

  • Linked-layer zoom. Animated SVG and GIF tours zoom through linked shapes as they enter or leave a layer, pause on a shared parent between sibling layers, and return to ancestors in one continuous pullback. Open the Atlas SVG and select Replay Worker to follow a delivery checkpoint down to the consumerโ€™s inbox; clicking linked shapes in standalone SVG or D2.js explores the destination directly.
The Atlas overview zooms into the replay workerโ€™s checkpoint flow, then into the consumerโ€™s deduplication transaction.

Edit the Atlas replay tour in Playground

  • Video export. Export 60 fps motion as H.264 MP4 (tour.mp4) or VP9 WebM (tour.webm) with FFmpeg 5.1 or newer. Configure dimensions, quality, and clip length with --video-size, --video-quality (low, medium, high, best), and --video-duration. Exports ยท Atlas MP4 ยท Atlas WebM
  • Motion review. Use d2 storyboard to put timestamped frames from every board into one PNG, and d2 lint --motion to report crowded transitions, short-lived labels, hidden caption targets, and possible shape ID replacements. Both are available through MCP as storyboard and lint_motion. Atlas storyboard ยท Motion review
  • Sequence diagrams v2. Use shape: sequence-diagram for explicit participant and message groups (actor-group, edge-group), branched frames (shape.branched), shared rows, activation labels, repeated headers (shape.mirrored, shape: sequence-diagram-checkpoint), numbered messages (shape.numbered), participant timeline notes (shape: page), and message annotations. Existing shape: sequence_diagram diagrams keep their original layout and emit a deprecation warning ahead of D2 1.0. Guide and example ยท #2662
  • TALA hierarchies. Branches and joins leave more room near box corners, grouped handoffs form aligned columns, parallel branches take symmetric routes, and TALA compares finished routes when choosing between compact placements. TALA ยท #3150
  • Source validation warnings. d2 validate points out explicit settings that D2 ignores and syntax that can draw a different diagram than intended, with rule codes and source locations. Use --max-warnings 0 in CI, --json for structured diagnostics, and --warn unmatched-glob or --warn overwritten-style for optional checks. Available in the CLI, language server (d2 lsp), MCP (check), Go (d2compiler.Validate), and D2.js (d2.validate()). #3147
  • Image shapes. Configure image sources and fitting under shape: image { src: ./photo.png; fit: cover; position: center-right }. shape.fit supports contain, cover, fill, none, and scale-down, and shape.position accepts named anchors. Existing icon sources continue to work, icon.style.border-radius rounds image corners (including through mixin classes), and shape.src: null clears an inherited source. Icons ยท #3149 ยท #3175
  • Composite primary keys. Declare multi-column SQL table primary keys with shape: sql-table { primary-key: [tenant_id; project_id] }. Adjacent columns in key order share one PK label, while separated or reordered columns show numbered PK labels. Use shape.primary-key: [] to clear an inherited key. The language server updates composite key members when renaming columns. Example ยท #3148

Improvements ๐Ÿงนโ€‹

  • Config theme keys. Use vars.d2-config.theme and vars.d2-config.dark-theme (accepting either theme names or numeric IDs, matching --theme and --dark-theme). theme-id and dark-theme-id remain accepted as aliases and emit deprecation warnings ahead of D2 1.0. #3179
  • Hyphenated shape and SQL constraint names. Use sql-table, stored-data, primary-key, and foreign-key to match D2โ€™s hyphenated naming convention. The underscore spellings (sql_table, stored_data, primary_key, foreign_key) remain accepted as aliases and emit deprecation warnings ahead of D2 1.0. #3174
  • 60 fps easing, playback progress, and reduced motion. Step tweens target 60 fps with cubic ease-in-out on display refresh, subpixel TALA pin movement, and cubic-bezier compression for uniform grid transitions. Timed exports show a faint playback track with gaps at board changes and a background-contrasting fill (animate-progress, animate-progress-color). Reduced-motion SVGs open on a still board and keep click navigation. Animation ยท #3114 ยท #3135 ยท #3136 ยท #3139 ยท #3161
  • Smaller SVG exports and WOFF2 fonts. Across 157 documentation diagrams, SVG output is 28.4% smaller raw and 35.1% smaller gzipped. D2 embeds smaller WOFF2 bundled and appendix fonts (retaining kerning, ligatures, and hinting) alongside more compact stylesheets, code blocks, arrowhead references, textures, sketch paths, and LaTeX glyphs. SVG benchmark ยท #3099 ยท #3101
  • Smaller release archives. Compressing release archives with libdeflate shrank the six CLI archives by about 0.8โ€“0.9 MB each. #3142 ยท #3144
  • Editor, LSP, and MCP. Added language server completions and hover docs for gradient colors and composite shape options (shape.{src,fit,position,primary-key,numbered,mirrored,branched}), synced the MCP guide and d2(1) man page with new flags and config keys, and aligned d2oracle.Delete with shape keywords. #3118 ยท #3170

Bugfixes โ›‘๏ธโ€‹

  • Sketch mode. Sketched rectangles (including double-bordered shapes) with style.border-radius now draw rounded corners in SVG as well as PNG, GIF, and video exports. #1098 ยท #3168 ยท #3172
  • Shared strokes and SVG rendering. Touching shape borders, shared connection segments, and coincident class or SQL table dividers draw at single-stroke weight in static diagrams. Labels that mention fill pattern class names such as paper-overlay no longer embed unused textures. Honored code font colors and whole-label text gradients, sanitized illegal XML 1.0 control characters in code blocks and legends, smoothed animated crossing gaps on large diagrams, fixed missing legend connections in Firefox, and preserved SVG fill patterns after dark-mode CSS in Apple ImageIO. #3126 ยท #3091 ยท #3089 ยท #3100 ยท #3131 ยท #3158
  • Annotations and captions. Enabled Markdown links in annotations and made caption cue resolution Markdown-aware. Included 3D/multiple extrusions and leaving captions in annotation bounds, preserved layer zooms and independent viewports on annotated layers, and rejected unsupported HTML in annotations during validation and compilation. #3152 ยท #3153 ยท #3156 ยท #3162 ยท #3163
  • Compiler, links, and validation. Unquoted HTTP and HTTPS links preserve URL #fragments (put a space before # for a trailing comment). Relative file links are preserved and unresolved board links are reported without leaking root. into unlabeled edge labels. Spreading a null edge attribute clears it while keeping the connection. Changing a composite shape (image or sql-table) to another shape type clears prior shape options. d2 validate validates vars.d2-legend image sources, rejects unknown --layout engines, and no longer emits false overwritten-style warnings on distinct unindexed parallel edges. #3130 ยท #3146 ยท #3157 ยท #3160 ยท #3166 ยท #3169 ยท #3173
  • Animations, video, and GIF. Raised the GIF total frame area ceiling from 160 to 256 Mi-pixels, stored opaque delta rectangles, and preserved long still holds without duplicate frames. Video and PNG exports now stage non-regular destinations such as /dev/null safely without renaming special files. Animated SVG icons render their base state in raster exports (svgposter and d2svgimport fixes). Fixed d2 lint --motion subpixel start detection, skipped unnecessary camera zoom filters when animate-duration: 0, canonicalized duplicate mask/marker IDs in native motion, and fixed negative-zero tween labels, gradient stop padding/tweens, and TALA arrival + paint composition. #3116 ยท #3117 ยท #3121 ยท #3127 ยท #3129 ยท #3132 ยท #3141 ยท #3151 ยท #3154 ยท #3155 ยท #3159 ยท #3164 ยท #3165 ยท #3167
  • Installer. Avoided false Homebrew installer shadow warnings. #3090

Breaking Changesโ€‹

  • Compiled d2target diagrams and JSON use hyphenated names. Compiled d2target output and JSON now emit sql-table, stored-data, primary-key, and foreign-key instead of underscore spellings. D2 source still accepts sql_table, stored_data, primary_key, and foreign_key with deprecation warnings ahead of D2 1.0. #3174
  • annotation is now a reserved keyword. Quote any existing shape literally named "annotation". #3085
  • CSS degree gradient angles. Degree gradients now start at the opposite edge and measure clockwise from up, matching CSS. #3123
  • Playback progress bar and animation timing. Timed animations reserve space for a playback progress bar by default; opt out with vars.d2-config.animate-progress: false or --animate-progress=false. Composed tours take animate-interval from the entry diagram; move board-local animate-interval values to the entry diagram. #3108 ยท #3119
  • Stricter d2 validate. d2 validate now compiles diagrams and imports, validates vars.d2-legend image sources and annotation HTML, and rejects unknown --layout engines. #3133 ยท #3160
  • WOFF2 bundled fonts. Bundled SVG font subsets now embed as WOFF2 instead of WOFF/TTF. #3099

D2.js 0.3.0โ€‹

The @d2lang/d2 package (and @terrastruct/d2 compatibility package) bumps to 0.3.0 for browsers and Node.js. #3176 ยท #3178

  • Validation API. d2.validate() checks D2 source and virtual imports in Node.js and browsers with the same default and optional warnings (unmatched-glob, overwritten-style) as d2 validate.
  • Animation and playback. RenderOptions adds animateProgress and animateProgressColor. Standalone SVGs support linked-layer click navigation, 60 fps eased transitions, animated scenarios, connection icons, and annotations.
  • Shapes and TypeScript. Includes sequence diagrams v2, image shape fitting (imageFit, imagePosition, iconBorderRadius), composite primary keys, and hyphenated d2target shape and constraint names. index.d.ts adds d2.validate(), d2.version(), d2.jsVersion(), and missing shape and config fields (Diagram.config.{layoutEngine,data}, ShapeBase.{iconBorderRadius,imageFit,imagePosition}).
  • WebAssembly size. Bundles all three layout engines plus sequence v2, annotations, and validation in 11.59 MB uncompressed and 3.94 MB Brotli inside the browser module.

Install D2 ยท All changes since v0.10.0

Contents