Graphviz
Graphviz is a graph layout system built around the DOT language. diagramkit renders .dot, .gv, and .graphviz files to SVG using bundled Viz.js/WASM — no browser needed.
File Extensions
.dot, .gv, .graphviz
Capability Matrix
| Capability | Graphviz |
|---|---|
| Browser required | No |
| Native dark mode support | Partial (post-process adaptation) |
| WCAG post-process | Yes |
Supports --no-contrast |
Yes |
| Multi-format output | SVG/PNG/JPEG/WebP/AVIF |
Quick Start
Create dependency.dot:
digraph Dependencies { rankdir=LR; Client -> Api; Api -> Auth; Api -> Database;}Render:
diagramkit render dependency.dotOutput:
.diagramkit/ dependency-light.svg dependency-dark.svgUsing with AI Agents
Tell your AI coding agent:
Render all graphviz dot files in this project to SVG
Or for more control:
Render docs/dependency.dot to PNG at 3x scale with light mode only
Dark Mode
Graphviz SVG defaults to black strokes and text. diagramkit adapts the output for dark mode:
- Renders with a transparent graph background
- Applies WCAG contrast optimization when
contrastOptimizeis enabled - Rewrites default black text and strokes to dark-surface-friendly colors
This keeps unstyled DOT diagrams readable on dark backgrounds while preserving any explicit non-black colors from the source.
# Skip contrast optimization for raw dark outputdiagramkit render . --no-contrastHow It Works
Graphviz rendering does not use the browser pool. diagramkit calls the bundled Viz.js/WASM renderer directly in Node.js, then passes the SVG through the standard output pipeline (theme variants, file naming, manifest, optional raster conversion).
Tip
Since Graphviz doesn’t need a browser, it renders faster than Mermaid, Excalidraw, or Draw.io. You can also skip diagramkit warmup if you only render Graphviz files.
Programmatic Usage
import { render } from 'diagramkit'const result = await render( `digraph { A -> B -> C }`, 'graphviz', { format: 'svg', theme: 'both' },)Gotchas
- Only
svgformat from Viz.js — Graphviz renders to SVG via WASM, then diagramkit converts to raster if needed. The DOTformatdirective is ignored; diagramkit always requests SVG. - Layout algorithms — Viz.js supports
dot,neato,fdp,sfdp,twopi, andcirco. The default isdot. Large graphs (500+ nodes) may be slow withneatoorfdp. - Dark mode adaptation — default black strokes become
#94a3b8and text becomes#e5e7eb. Only unstyled (black) elements are affected; explicitly colored elements are preserved. - No browser needed — Graphviz is the only engine that skips the browser pool. It renders faster and does not require
diagramkit warmup.
Tips
- Use
rankdir=LRfor dependency graphs and pipelines that read left-to-right - Use
subgraph cluster_*blocks to group related nodes - Leave colors mostly unstyled — the dark adaptation works best with Graphviz defaults
- Keep labels short — wrap long names with
\nso auto-layout stays readable