Generate and edit SVG diagrams using svg++ and the diagramagic CLI
Diagramagic helps LLMs create better, larger diagrams more easily by keeping SVG familiar and adding minimal layout extensions.
You generate diagrams using svg++ (SVG with diag: layout extensions) and the diagramagic CLI tool.
Run these commands and use their output as your syntax reference:
diagramagic cheatsheetdiagramagic patterns.svg++ filediagramagic render <file>.svg++ to generate PNGdiagramagic compile <file>.svg++ for final SVGYou are writing SVG. The diag: extensions handle layout and sizing — they do not replace your responsibility to create rich, detailed, information-dense diagrams. Write with the same visual quality and detail you would if generating raw SVG. The diag: features save you from coordinate math, not from doing the actual design work.
<diag:diagram> root with xmlns="http://www.w3.org/2000/svg" and xmlns:diag="https://diagramagic.ai/ns"diag:flex for layout structure (stacks, rows, grids of cards) — but fill those containers with rich, detailed contentdiag:graph for auto-layout when topology matters (flowcharts, dependency graphs) — but treat it as scaffolding, not the complete designlayout="layered" for flowcharts, request pipelines, dependency chainslayout="radial" for hub-and-spoke systemslayout="circular" for peer/cyclic systemsrouting="auto" as defaultrouting="ortho"/"polyline" for dense technical diagrams where readability matters mostrouting="curved" for lighter conceptual diagrams; avoid it for dense feedback-heavy graphsdiag:node gap="6" to gap="12" to avoid cramped text blocksdiag:include or switch to a hybrid flex + arrows structurediag:wrap="true" on <text> for multi-line text (wrapping is a text feature, not a diag:node feature)diag:arrow with id-tagged elements for connectorslabel-rotate="horizontal" for readable arrow/edge labels by default; use follow only when line-following text is intentionally desireddiag:anchor for precise named points (sequence diagrams, etc.)diag:include to compose large diagrams from sub-filesdiag:template when you have 3+ visually identical elements (e.g., entity cards, service boxes)<rect>, <line>, <circle>, <path> for decorative elements, region backgrounds, custom shapeslayout="circular" and layout="radial" require system Graphviz (dot) on PATH; layered layout can fall back if unavailableE_PARSE_XML: fix malformed XML and retryE_SVGPP_SEMANTIC: fix svg++ structure/ids and retryE_INCLUDE_ID_COLLISION: rename conflicting ids between parent and included filesE_GRAPH_UNKNOWN_NODE: ensure every diag:edge from/to id exists as a diag:node in the same graphE_GRAPH_SELF_EDGE: remove or redesign self-referential diag:edge (from == to)E_GRAPH_TOO_LARGE: split the graph into smaller sections or compose with diag:include