SQL to ER Diagram Converter

Paste your DDL, a database dump or a Prisma schema. Every table, column type, primary key and foreign key is read from the file itself, not guessed

0/20000• 1 free diagram left today
Try:

No sign-up required • Free to try

Example

SQL to ER Diagram Converter example, generated from one sentence

Prompt: “CREATE TABLE users (id serial PRIMARY KEY, email text UNIQUE NOT NULL, created_at timestamptz); CREATE TABLE teams (id serial PRIMARY KEY, name text); CREATE TABLE team_members (team_id int REFERENCES teams(id), user_id int REFERENCES users(id), role text, PRIMARY KEY (team_id, user_id)); CREATE TABLE orders (id serial PRIMARY KEY, user_id int REFERENCES users(id), total numeric(10,2), status text);”

SQL to ER Diagram Converter example generated by Datadef: CREATE TABLE users (id serial PRIMARY KEY, email text UNIQUE NOT NULL, created_at timestamptz); CREATE TABLE teams (id serial PRIMARY KEY, name text); CREATE TABLE team_members (team_id int REFERENCES teams(id), user_id int REFERENCES users(id), role text, PRIMARY KEY (team_id, user_id)); CREATE TABLE orders (id serial PRIMARY KEY, user_id int REFERENCES users(id), total numeric(10,2), status text);
Open this example on the canvas →Every box, arrow and label is editable, and the result exports to PNG or embeds live.

Parsed, not guessed

When the prompt is a schema, Datadef reads it instead of asking a model to redraw it. Tables, column types, composite primary keys, inline REFERENCES and ALTER TABLE ... ADD FOREIGN KEY constraints all come from the text, so a forty-table dump comes out with forty tables and nothing renamed. It takes a second or two.

Warehouse DDL rarely declares foreign keys. When a schema has none, links are read from the key names instead (fct_sales.customer_key to dim_customer.customer_key, orders.customer_id to customers) and drawn dashed, with a note saying so, so nobody mistakes an inferred link for a constraint.

Longer than the prompt box? Paste it anyway: a long paste becomes an attachment and is read whole. You can also attach a .sql or .prisma file. Add a sentence like "turn these tables into a star schema" and the request goes to the AI designer instead, with your DDL as the source.

Designing a star schema from scratch →

Frequently Asked Questions

Common questions about sql to er diagram converter

Which SQL dialects can I paste?▼

PostgreSQL (including pg_dump output), MySQL and MariaDB dumps, SQL Server with bracketed names, Snowflake, BigQuery, Redshift and Oracle DDL. The CREATE TABLE and ALTER TABLE structure is read, never executed, and statements it does not need (INSERT, SET, LOCK) are ignored.

Does it work with Prisma?▼

Yes. Paste schema.prisma or attach it: models become tables, @id and @@id become primary keys, and every @relation(fields, references) becomes a foreign key between the right columns. Relation fields such as posts Post[] are not drawn as columns.

Do I need to connect my database?▼

No. Everything works from pasted DDL or an attached .sql file, so there is nothing to install, no credentials to hand over, and it works for schemas you only have as migration files.

What if my DDL has no foreign keys?▼

Common in warehouses. Links are inferred from matching key names and drawn dashed, and a note on the canvas says how many were inferred, so you can check them before sharing.

Can I keep the diagram in sync as the schema evolves?▼

Connect the repository and the diagram is redrawn when the schema changes, or use the Datadef MCP server so your coding agent passes the migration files to create_diagram directly.

Ready to create your diagram?

Try it free on the scratch canvas, no account needed. Pro starts with a 7-day free trial.

View All Generators