SQL to DBML
Paste your SQL CREATE TABLE statements and export them as DBML — ready for dbdiagram.io and other DBML tools — while you preview the live ER diagram.
At a glance
- What it is
- SQL to ER Diagram is a free, open-source browser tool that turns SQL
CREATE TABLEstatements into DBML. - Input
- SQL
CREATE TABLEstatements for PostgreSQL, MySQL, MariaDB, SQLite, SQL Server, Oracle or Snowflake. - Output
- DBML code to copy, alongside a live interactive diagram.
- Cost
- Free. MIT-licensed open source. No account or signup.
- Privacy
- Runs entirely in your browser. The schema is never uploaded, and share links carry the diagram in the URL fragment, which is not sent to a server.
- Limits
- It never connects to your database itself: you paste schema text, or run one read-only catalog query in your own client and paste the result. There are no accounts, so there is no real-time multi-user editing; diagrams are kept in your browser, as a saved file, or as a share link. Layout stays smooth at around 300 tables.
How it works
- Paste your SQL schema into the editor (PostgreSQL, MySQL, SQLite, SQL Server, Oracle…).
- The diagram renders instantly so you can confirm the tables and relations.
- Click Export → DBML and copy the result.
- Paste it into dbdiagram.io or any DBML-based workflow.
Example
This SQL:
CREATE TABLE customers ( id BIGINT PRIMARY KEY, name VARCHAR(120) NOT NULL ); CREATE TABLE invoices ( id BIGINT PRIMARY KEY, customer_id BIGINT NOT NULL REFERENCES customers(id), total NUMERIC(10,2) );
…exports as this DBML:
Table "customers" {
"id" bigint [pk]
"name" varchar(120) [not null]
}
Table "invoices" {
"id" bigint [pk]
"customer_id" bigint [not null]
"total" "numeric(10,2)"
}
Ref: "invoices"."customer_id" > "customers"."id"
Copy it from Export → DBML. Try it with your own →
Guide
The conversion is deliberately boring and predictable: CREATE TABLE users becomes Table users, column types are normalised to DBML's style (SERIAL → serial with [pk, increment]), NOT NULL becomes [not null], UNIQUE becomes [unique], and each foreign key — whether inline or in an ALTER TABLE — becomes a Ref: line. Nothing is invented, nothing is dropped silently.
Why people convert SQL to DBML:
- dbdiagram.io import — DBML is its native format; paste and it renders.
- Readable diffs — a 400-line DDL dump becomes a 400-line DBML file that reads like documentation and reviews well in PRs.
- Toolchain entry — dbml-cli, dbdocs and several schema tools speak DBML, so it's the interchange step out of a raw dump.
The live diagram on this page is the verification step: if the canvas shows the relations you expect, the DBML contains them too — both come from the same parse. Export, copy, done. And since the conversion is client-side, production dumps with real table and column names never leave your machine.
Why use it
- Private: everything runs in your browser — nothing is uploaded or stored on a server.
- dbdiagram.io-ready DBML output.
- Verify visually — see the live diagram before you copy.
- Free & open source — no account, no sign-up.
FAQ
How do I convert SQL to DBML?
Paste your CREATE TABLE statements, then click Export → DBML and copy the output. Tables become Table blocks and foreign keys become Ref: lines.
Is this a free dbdiagram importer?
Yes — convert SQL to DBML for free and paste it straight into dbdiagram.io, with no account.
Is my schema uploaded anywhere?
No. Everything runs locally in your browser — your schema is never uploaded to or stored on any server.
Is it free?
Yes. It is completely free and open source, with no account or sign-up required.