d2-to-drawio: convert D2 diagrams to editable draw.io files #2777
Moawiah188
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I built a converter that turns D2 source into native draw.io / diagrams.net files: shapes, containers, edges, styles, themes, and layout positions all come across as editable elements, not an exported image.
It runs the official D2 WASM build (@terrastruct/d2) for parsing and layout, so vars, globs, classes, and imports behave exactly like d2 itself. Boards become draw.io pages. Unsupported features degrade with warnings instead of failing, and a feature matrix documents exactly what converts fully, partially, or not at all.
A workflow this unlocks: LLMs write D2 fluently (no coordinates to invent, autolayout does the placement), so you can draft a diagram with Claude or ChatGPT, convert, and hand-polish the result in draw.io instead of being stuck with an SVG.
npx d2-to-drawio diagram.d2 -o diagram.drawio
Repo: https://github.com/Moawiah188/d2-to-drawio
Feedback and broken .d2 samples very welcome.
All reactions