Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

DBML is a readable, open-source language for describing database schemas in text. Use it to document tables and relationships, make an ER diagram, or convert schemas to and from supported SQL dialects. It is not a database engine, a migration system, or a general-purpose programming language: a DBML file describes structure, while separate tools handle visualization, conversion, or schema extraction.

What is DBML?

DBML stands for Database Markup Language. It gives you a concise way to express database structure—such as tables, columns, keys, enums, and relationships—in a text file. The format can be read and edited directly, kept with application code, and used by compatible diagramming and documentation tools. Those are workflow options, not a guarantee of better collaboration or fewer errors.

The DBML project distinguishes its language from Microsoft’s separate DBML XML file extension; the shared acronym does not mean they are the same format. The project reports that 2.5 million DBML documents had been created through dbdiagram.io and dbdocs.io as of February 2025. This is a project-published usage figure, not an independent market estimate. DBML project overview

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How does DBML describe a schema?

A DBML file uses named blocks for database objects and concise declarations for columns and references. This small example defines two tables and a one-to-many relationship from users to posts:

Table users {
  id integer [primary key]
  username varchar
}

Table posts {
  id integer [primary key]
  user_id integer [not null]
  title varchar
}

Ref: posts.user_id > users.id

The Ref line says each post points to a user, while a user can be associated with multiple posts. DBML can also declare references inline with a column or separately, as above. Relationship options include referential actions such as cascade, restrict, set null, set default, and no action.

Projects, schemas, and documentation

A Project block can record project-level details, including the database type and a note. You can declare schemas explicitly and qualify table names when a database uses them. Tables can also include enums and notes about the purpose of a table or column. Notes and other visualization-oriented details help explain a schema, but they do not all have direct SQL equivalents.

Many-to-many relationships and example records

DBML supports a many-to-many relationship using <>, or you can model it through two many-to-one relationships and a join table. These forms communicate related structures, but they can differ in how the relationship maps to physical design when exported to SQL. Check the generated DDL against the schema you intend to deploy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Example records can be marked with [example] for documentation. The syntax guide says these records remain in DBML output but are excluded from SQL INSERT statements during export. Treat them as illustrative data, not production records. The DBML syntax guide documents these constructs.

How do I convert SQL to DBML?

For supported SQL dialects, DBML’s tools can import DDL—SQL statements that define database objects—and produce a DBML representation. The exact method depends on whether you want a command-line workflow, an application integration, or a schema pulled from a live database. Importing SQL DDL is distinct from connecting to a database: the former reads schema statements, while a connector extracts schema information from a supported database.

The official ecosystem lists @dbml/core for parsing DBML and converting SQL DDL to and from DBML in Node or a browser, and @dbml/cli for command-line conversion and schema pulls. Review the package documentation and current support matrix before choosing a workflow. Official DBML ecosystem and package information

Rank #3

Can DBML generate SQL?

Yes, compatible tooling can export DBML to SQL DDL for supported database types. That generates schema statements; it does not run them against a database, manage deployment, or replace a migration process. Review and test generated SQL in the context of your database and existing migration workflow before applying it.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

DBML also includes constructs intended for diagrams or documentation that have no SQL equivalent. These annotations may be useful in a DBML file while being absent from exported SQL. DBML enrichment and visualization constructs

What databases does DBML support?

Support depends on the operation. The following matrix reflects the official DBML package page as checked on October 7, 2026; it describes the listed packages, not every third-party tool. Compatibility can change, so consult the current official page when selecting a workflow.

Database SQL import to DBML DBML export to SQL Connector for schema extraction
PostgreSQL Yes Yes Yes
MySQL Yes Yes Yes
MSSQL / SQL Server Yes Yes Yes
Oracle Yes Yes Yes
Snowflake Yes No Yes
BigQuery No No Yes

A connector can extract a schema even where SQL import or export is not listed. In particular, the matrix lists Snowflake for import and connectors, but not export; BigQuery is listed for connectors only. Do not infer that one form of support implies the others.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How do I make an ER diagram from a DBML file?

Use a diagramming tool that accepts DBML. The official ecosystem lists dbdiagram for creating ER diagrams by writing code. A typical workflow is to write or import a schema as DBML, open it in a compatible diagramming tool, then review the rendered relationships and annotations. The diagram is a visualization of the schema description; it does not by itself create or alter a live database. dbdiagram introduction

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Which DBML workflow fits your goal?

  • Keep schema notes with code: Store a DBML file in a repository so changes to the description can be reviewed alongside application code. This is a practical option enabled by the text format and CLI tooling, not a measured collaboration outcome.
  • Visualize relationships: Use a compatible diagramming tool when a visual ER diagram is more useful than reading the text directly.
  • Publish searchable documentation: The official ecosystem lists dbdocs for database documentation. Notes and descriptions can make a schema more understandable to readers.
  • Start from existing SQL: Use SQL-to-DBML import when the dialect is listed for import in the support matrix.
  • Start from a live database: Use a listed connector to extract schema information, then inspect the result before relying on it as documentation.
  • Generate DDL: Export DBML only for a database type with export support, and treat the output as schema statements to review within your normal deployment process.

DBML is most useful when you want schema structure in a readable, tool-supported text format. If your central need is deployment or change management, it can complement—but does not replace—your database engine, SQL knowledge, or migration workflow.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.