Skip to content

SQL schema to DBML

Turn CREATE TABLE statements into a DBML diagram definition.

Input
Output

SQL schema to DBML

Paste one or more CREATE TABLE statements and this tool returns the equivalent DBML — the plain-text format used by dbdiagram.io and similar entity-relationship diagram tools. Every table becomes a Table block, every column keeps its name and type, and primary keys, unique constraints and foreign keys are carried over automatically. It is built for the moment you have a schema dump and need a diagram fast, without pasting SQL into a hosted service.

The dialect option tells the parser what it is reading — MySQL, PostgreSQL, SQLite or SQL Server — since the same keyword can mean different things across engines (a MySQL TINYINT(1) reads as a boolean, a SQL Server IDENTITY column reads as auto-increment). Turn on type mapping to collapse dialect-specific types into DBML's canonical set (int, varchar, decimal, timestamp and so on), or leave it off to keep the original names. Comments — a MySQL COMMENT clause or a PostgreSQL COMMENT ON statement — become DBML Note entries when "Keep comments" is on. Column names like user_id can optionally infer a relationship to a users table even without an explicit foreign key, and tables sharing a naming prefix (shop_orders, shop_products) can be grouped into a TableGroup.

The tool understands inline REFERENCES clauses, table-level FOREIGN KEY constraints and separate ALTER TABLE ADD CONSTRAINT statements, so it works on a single CREATE TABLE block or a full dump with keys added afterward. Composite primary keys and unique constraints are rendered as DBML indexes blocks rather than being dropped.

Everything runs locally in your browser — no schema is ever uploaded anywhere, which matters when the SQL you are pasting describes a real production database. Copy the DBML, download it as a .txt file, or send the output straight into another tool to keep working on it.

FAQ

Which SQL dialects are supported?
MySQL, PostgreSQL, SQLite and SQL Server. Pick the matching dialect so type mapping and auto-increment detection read the SQL correctly.
How are foreign keys detected?
From inline REFERENCES clauses, table-level FOREIGN KEY constraints, and separate ALTER TABLE ADD CONSTRAINT ... FOREIGN KEY statements — all three are converted into DBML Ref lines.
What does "infer relationships from column names" do?
When a column is named like user_id and no explicit foreign key exists, the tool checks for a matching users table with an id column and adds a Ref for it, marked as inferred in the output.
Can I paste the output straight into dbdiagram.io?
Yes. The output is plain DBML — tables, columns, keys and relationships — in the format dbdiagram.io and compatible tools expect.
Is my schema uploaded anywhere?
No. The SQL you paste is parsed entirely in your browser and never leaves your device.