Free tool

Convert SQL to DBML

Paste a schema from PostgreSQL, MySQL, or SQL Server and get it back as DBML: every table, column, key, index, and enum, in a text format short enough to read and review.

Free, no account. Your schema is converted on our server and not stored. Up to 200 KB.

What comes across

  • Tables and columns, with each column type kept exactly as it was written. Multi-word PostgreSQL types such as timestamp with time zone and double precision survive whole, which is where many converters lose a word.
  • Primary and foreign keys, whether declared inline, as a table constraint, or added afterwards with ALTER TABLE. Each foreign key becomes a Ref.
  • Unique and not-null constraints, defaults, and indexes.
  • Enums: a PostgreSQL CREATE TYPE ... AS ENUM becomes a DBML Enum, and the columns that use it keep pointing at it.

A database with several schemas becomes several documents

If the dump creates tables in more than one database schema, each schema is returned as its own DBML document, named after it. References between them are written with the qualified name, so they still resolve when the documents are read together:

auth.dbml + billing.dbml dbml
// auth.dbml
Table "auth"."users" {
  "id" int [pk]
}

// billing.dbml
Table "billing"."invoices" {
  "id" int [pk]
  "user_id" int
}

Ref:"auth"."users"."id" < "billing"."invoices"."user_id"

That split is how large schemas stay readable. DB Planner resolves every document in a project together, so a table in one file can reference a table in another with no import lines.

What to do with the DBML

DBML is a good format to keep a schema in: it diffs cleanly in a pull request and it reads without a database to hand. It is also the text DB Planner draws from, so pasting the result into a project gives you the ER diagram of your SQL. To go the other way, convert DBML back to SQL for any of the three databases, and if you are new to the format, start with what DBML is.

SQL to DBML questions

Is the SQL to DBML converter free?

Yes. It runs on this page with no account and no limit on how often you use it. A single paste can be up to 200 KB, which covers schemas of several hundred tables.

Which SQL dialects does it convert?

PostgreSQL, MySQL, and SQL Server. The dialect is detected from the syntax of what you paste, so there is nothing to choose, and if the first reading fails the other two are tried.

Does it read my data?

No. It reads CREATE TABLE and related statements only. INSERT statements in a dump are ignored, and the schema you paste is converted and returned without being stored.

What happens to views, functions, and triggers?

They are skipped. DBML describes tables, columns, relationships, indexes, and enums, and has no syntax for the rest, so a converter that kept them would have nowhere to put them.

Put your schema on the board

Start on the free plan, no card needed. Pro is $5 a month when you outgrow it.

Start designing free