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.
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 users ( id SERIAL PRIMARY KEY, email TEXT UNIQUE ); CREATE TABLE posts ( id SERIAL PRIMARY KEY, user_id INT REFERENCES users(id) );
…exports as this DBML:
Table users {
id serial [pk]
email text [unique]
}
Table posts {
id serial [pk]
user_id int
}
Ref: posts.user_id > users.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.