D2

v0.10.1
io.github.d2lang/d2 Checked 1 hour ago Published 17 hours ago

Look up D2 syntax, render diagrams locally, and review animations with storyboards and motion lint.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

guide D2 language guide

Return the D2 language guide for the D2 version this server runs. Call it once before writing D2 if you have not read it in this conversation. Topic "core" covers syntax, house style and common mistakes. Topic "reference" lists every shape, style keyword, arrowhead, theme and layout engine.

ParameterTypeDescription
topicstringcore: syntax, house style and common mistakes. reference: every shape, style keyword, arrowhead, theme and layout engine. Default core.

check Check D2 source

Check D2 source without rendering. Returns errors and advisory warnings with source positions. Warnings include a rule code. Set fmt to true to also get the canonically formatted source.

ParameterTypeDescription
fmtbooleanAlso return the canonically formatted source. Default false.
layoutstringOverride the diagram's layout engine for layout-dependent warnings. No layout is run.
pathstringPath to a .d2 file, absolute or relative to the server root. Available only when the server was started with --root. Pass exactly one of source and path.
sourcestringD2 source text. Pass exactly one of source and path.
warnarrayEnable optional source warnings in addition to the defaults.

lint_motion Lint D2 motion

Review the animation timeline for motion and readability issues. Returns advisory diagnostics with board paths, source positions, rule codes, and suggestions. Use storyboard to inspect the result after editing.

ParameterTypeDescription
animate_durationintegerTransition duration in milliseconds for steps, scenarios, and linked-layer zooms. Omit to use the source setting. Zero disables interpolation.
animate_intervalintegerMinimum milliseconds per board. Omit to use the source setting. The default is 1000 ms.
layoutstringLayout engine. Omit to use the diagram's own setting, which defaults to dagre. Use tala for software architecture diagrams with containers.
pathstringPath to a .d2 file, absolute or relative to the server root. Available only when the server was started with --root. Pass exactly one of source and path.
sketchbooleanHand-drawn look.
sourcestringD2 source text. Pass exactly one of source and path.
themeintegerTheme ID. Omit to use the diagram's own setting. Call guide with topic reference for the list.

render Render D2 diagram

Compile D2 source and return the rendered diagram. By default returns a PNG image you can look at. If the source has errors, returns them with line and column so you can fix the source and call render again. Always look at the result before telling the user the diagram is done: check that nothing overlaps, that text is readable, and that the flow reads in the direction you intended.

ParameterTypeDescription
formatstringpng (default) returns an image you can look at. txt returns a text drawing, the cheapest way to check structure. svg returns the full SVG source, which is large: ask for it only to save a file.
layoutstringLayout engine. Omit to use the diagram's own setting, which defaults to dagre. Use tala for software architecture diagrams with containers.
max_dimensionintegerpng only. Longest side of the image in pixels, from 256 to 4096. Default 1568.
pathstringPath to a .d2 file, absolute or relative to the server root. Available only when the server was started with --root. Pass exactly one of source and path.
sketchbooleanHand-drawn look.
sourcestringD2 source text. Pass exactly one of source and path.
targetstringBoard to render, for example layers.api or scenarios.failover. Omit for the root board.
themeintegerTheme ID. Omit to use the diagram's own setting. Call guide with topic reference for the list.

storyboard Review a D2 animation

Return one PNG contact sheet sampled from the animation timeline. Inspect the labeled frames in playback order. Frame metadata gives the board path and timestamp in milliseconds for each panel.

ParameterTypeDescription
animate_durationintegerTransition duration in milliseconds for steps, scenarios, and linked-layer zooms. Omit to use the source setting. Zero disables interpolation.
animate_intervalintegerMinimum milliseconds per board. Omit to use the source setting. The default is 1000 ms.
layoutstringLayout engine. Omit to use the diagram's own setting, which defaults to dagre. Use tala for software architecture diagrams with containers.
pathstringPath to a .d2 file, absolute or relative to the server root. Available only when the server was started with --root. Pass exactly one of source and path.
sketchbooleanHand-drawn look.
sourcestringD2 source text. Pass exactly one of source and path.
themeintegerTheme ID. Omit to use the diagram's own setting. Call guide with topic reference for the list.