Terrastruct open-sources TALA, its D2 diagram layout engine

Terrastruct has open-sourced TALA (Terrastruct's AutoLayout Algorithm) under MPL-2.0, the same license D2 already uses. TALA now ships bundled in D2 v0.9.0 and can be tried by installing D2 and passing --layout=tala, or directly in the browser at play.d2lang.com, which runs entirely client side.
TALA is an orthogonal autolayout engine built with software architecture diagrams in mind, in contrast to the DAG-based Dagre and ELK engines D2 already includes, which grow in one direction. TALA instead produces layouts closer to what someone might sketch on a whiteboard. It combines ideas from graph-drawing research papers cited in its source code with original techniques, scoring candidate layouts against multiple aesthetic objectives, including symmetry, median distance, flow and the clustering of similar nodes.
A distinctive feature is that node positions and sizes can be pinned explicitly, including a hybrid mode where some nodes get fixed coordinates and the rest are placed automatically by the engine. The announcement frames this as well suited to agentic use: models can draw well in 2D space but still struggle with routing, which TALA continues to handle even when coordinates are supplied.
The post backs this up with two sets of examples. The first is seven layout comparisons using public D2 diagram files pulled from D2's real-world fixtures, rendered with TALA against Dagre and ELK; the author says these were not hand-picked. The second is eleven diagrams described as original, fictional compositions generated with the help of AI, demonstrating custom and partial node positioning.
The author also lists tradeoffs. TALA has randomness built in: by default it tries three random seeds and keeps the best-scored layout. The same seeds and input reproduce the same diagram, but adding a single node can make the whole layout look completely different, whereas Dagre and ELK keep the prior structure and simply accommodate the new node. TALA also handles long, flowing DAGs less well than Dagre or ELK, and its runtime scales nonlinearly, taking longer on larger diagrams; a separate d2-benchmarks repository is linked for runtime comparisons. The post thanks contributors Gavin Nishizawa, for broad contributions across TALA, and Júlio César Batista, for work on hierarchy algorithms and more.
Key facts
- Terrastruct open-sourced TALA under MPL-2.0, the same license as D2; it ships bundled in D2 v0.9.0 and is enabled with --layout=tala.
- TALA is an orthogonal layout engine built for software-architecture-style diagrams, unlike the DAG-based Dagre and ELK engines D2 already ships.
- Node positions and sizes can be pinned explicitly, mixed with automatic placement, which the author says suits AI-agent-generated diagrams where models place shapes but still struggle with routing.
- TALA uses a default of 3 random seeds and keeps the best-scored layout; results are deterministic per seed, but adding a single node can reshuffle the whole diagram, unlike Dagre and ELK.
- TALA handles long, flowing DAGs less well than Dagre or ELK, and its runtime scales nonlinearly, taking longer on larger diagrams.
Why it matters
TALA is Terrastruct's own layout algorithm for the D2 diagramming language, and open-sourcing it under the same MPL-2.0 license as D2 puts the engine's source, including the graph-drawing research it draws on, in the open alongside the language itself. Unlike D2's existing Dagre and ELK layout engines, which are DAG-based and grow diagrams in one direction, TALA is an orthogonal layout engine aimed at software architecture diagrams, scoring candidate layouts on objectives such as symmetry, median distance, flow and clustering of similar nodes to produce something closer to a whiteboard sketch.
Who it affects
It affects anyone using D2 to draw architecture-style diagrams, since TALA is now a built-in layout option rather than a closed feature, and the wider D2 contributor community, which can now inspect and modify the algorithm itself. It also affects people building AI agents that generate diagrams: the author points to TALA's support for explicit node coordinates as a fit for models that can place shapes in 2D space but still struggle with routing connections between them.
How to use it
TALA is bundled into D2 v0.9.0, so installing that version and passing --layout=tala switches the layout engine. It can also be tried without installing anything at play.d2lang.com, which runs entirely client-side. Positions and sizes of individual nodes can be locked to explicit coordinates, and this can be mixed with automatic placement so that only some nodes are pinned while the rest are laid out by the engine.
How solid is it
The announcement backs its claims with two sets of examples rather than abstract description. Seven comparisons use public D2 diagram files taken from D2's real-world fixtures, rendered with TALA, Dagre and ELK side by side; the author states these were not hand-picked, though notes some viewers may still prefer a non-TALA layout in individual cases. A further eleven diagrams, described as original fictional compositions generated with AI assistance, demonstrate custom and partial node positioning. For runtime performance, the post does not give benchmark figures directly but links to a separate d2-benchmarks repository comparing TALA's speed against Dagre and ELK.
Risks and caveats
TALA has randomness in it: by default it tries three random seeds and keeps whichever layout scores best. Given the same seeds and the same input it reproduces the same diagram, but adding just one more node can make the result look completely different, whereas Dagre and ELK tend to keep the prior layout intact and simply fit the new node in, which the author notes is sometimes the more desirable behavior. TALA also does less well on long, flowing DAGs, where the author says they still prefer Dagre or ELK, and its runtime scales nonlinearly, so it can take noticeably longer to run on larger diagrams.
“Given the same seeds and same input, it'll produce the same diagram. But let's say you just add one more node. The diagram could look completely different. In Dagre and ELK, it looks mostly the same as prior, with the extra node accommodated for.”
— Terrastruct's TALA open-source announcement