Skip to content

Commands Overview

d2vision provides commands for working with D2 diagrams.

Command Summary

Command Description
parse Extract structure from D2-generated SVGs
generate Create D2 code from structured specifications
template Generate common diagram patterns
pipeline Generate workflow diagrams from PipelineSpec
convert Convert Mermaid/PlantUML diagrams to D2
learn Reverse engineer D2 code from SVGs
lint Check D2 files for layout issues
diff Compare two diagrams
watch Auto-render D2 files on changes
analyze Analyze layout and provide generation hints
icons Browse and search D2's icon library
rotate Rotate SVG by 90° increments

Common Flags

All commands support:

  • -h, --help - Show help for the command
  • -f, --format - Output format (varies by command)

Pipeline Usage

Commands are designed to work well in Unix pipelines:

# Template → D2 → SVG
d2vision template microservices --d2 | d2 - output.svg

# Learn → Modify → Generate → Render
d2vision learn old.svg > spec.toon
# ... edit spec.toon ...
d2vision generate spec.toon | d2 - new.svg

# Lint before rendering
d2vision lint diagram.d2 && d2 diagram.d2 output.svg