DBML to PNG | Quick, Free Diagram Image

3 min read Original article ↗

How It Works

  1. Paste your DBML. DBML (Database Markup Language) is a convenient, well-known language for defining database schemas. A brief DBML reference is given below.
  2. Click Generate. VibeSchema lays out your tables automatically and renders a diagram preview.
  3. Download the PNG. Click Download PNG to save a high-resolution image of your diagram.

Want an SVG instead? Use the DBML to SVG tool.

Quick DBML reference

Tables

Table users {
  id         integer
  name       varchar
  email      varchar
  created_at timestamp
}

Tables with constraints

Table users {
  id         integer   [pk]
  email      varchar   [unique, not null]
  name       varchar   [not null]
  role       varchar   [default: 'member']
  created_at timestamp
}

Relationships — inline and standalone

// Inline ref on the column
Table posts {
  id      integer [pk]
  user_id integer [ref: > users.id]
  title   varchar
}

// Standalone ref block
Ref: comments.post_id > posts.id

Enums

Enum order_status {
  pending
  processing
  shipped
  cancelled
}

Table orders {
  id     integer      [pk]
  status order_status [default: 'pending']
}

Relationship cardinality

// Many-to-one  (many orders belong to one user)
Ref: orders.user_id > users.id

// One-to-many  (one user has many orders)
Ref: users.id < orders.user_id

// One-to-one   (each user has one profile)
Ref: users.profile_id - profiles.id

Many-to-many (junction tables)

VibeSchema does not render the DBML <> many-to-many shorthand. Model the relationship with an explicit junction table instead, which gives you two separate one-to-many edges in the diagram and lets you attach extra columns to the relationship.

Table students {
  id   integer [pk]
  name varchar
}

Table courses {
  id    integer [pk]
  title varchar
}

Table enrollments {
  student_id  integer   [ref: > students.id]
  course_id   integer   [ref: > courses.id]
  enrolled_at timestamp
  grade       varchar
}

Why Export DBML as PNG

Embedding a DBML diagram image in your README, wiki, or design doc makes the data model immediately understandable to anyone on the team. A single PNG can replace pages of written explanation when onboarding new developers or reviewing a database design.

DBML diagram images are also useful for architecture reviews, technical blog posts, and slide decks. Because VibeSchema's PNG export renders the full canvas at high resolution and adapts to the size of the actual schema, the output looks sharp whether it's displayed inline or projected on a screen.

Comparing Two Schemas?

If you want to visualize what changed between two versions of a schema, use the Database Diagram Diff Tool. Paste a before and after schema and get a color-coded diagram showing exactly what was added, modified, or removed.

Free, No Sign-Up

VibeSchema is free to use. No account required. Paste your DBML above and download the PNG.