Skip to content

Generate D2 ERD

1. Install D2 CLI

# With --dry-run the install script will print the commands it will use
# to install without actually installing so you know what it's going to do.
curl -fsSL https://d2lang.com/install.sh | sh -s -- --dry-run
# If things look good, install for real.
curl -fsSL https://d2lang.com/install.sh | sh -s --

Check installations for more details

2. Generate D2 ERD content

dbterd run -t d2 -ad "samples/dbtresto" -o "target" -s schema:dbt.mart 2023-05-06 08:17:54,413 - dbterd - INFO - Run with dbterd==?.?.? (main.py:54) 2023-05-06 08:17:54,715 - dbterd - INFO - target/output.d2 (base.py:75)

2. Export to SVG

d2 -w ./target/output.d2 ./target/output.svg

3. Embeded into Markdown

# Sample D2 ERD

![d2](./target/output.svg)

Sample Output:

d2