SQL to ERD — Generate an ER Diagram from a SQL Script
If you have an existing database and want to see its structure visually, you don't need to rebuild
the diagram by hand. SQL Designer can parse a CREATE TABLE SQL script and generate an
ER diagram from it automatically — rendering tables, columns, data types, constraints, and foreign
key relationships on a visual canvas in seconds.
What Is SQL to ERD Conversion?
SQL to ERD conversion (also called SQL to ER diagram or SQL schema import) means taking a DDL
script — a set of CREATE TABLE statements — and rendering it as a visual
entity-relationship diagram. The tool reads your SQL, identifies each table and its columns,
detects FOREIGN KEY constraints, and draws the corresponding relationships on a canvas.
The result is the same ERD you would have drawn from scratch, but generated automatically from SQL you already have. It's the reverse of the more common workflow (design visually, then export SQL) — which is why it's often called reverse engineering a database schema.
Why Generate an ERD from SQL?
There are several common reasons to convert an existing SQL schema to a diagram:
- Documentation — the schema exists only as migration files or a raw DDL dump, and you need a diagram to share with the team or include in technical docs
- Onboarding — a new developer joins and needs to understand the database structure quickly; a diagram is far faster to read than
SHOW CREATE TABLEoutput - Audit and review — before adding a major feature, you want to see how the current schema is structured to plan new tables and relationships
- Legacy databases — the database was built without any visual design tool and no diagram has ever existed
- Refactoring — you want to visualise the current state before deciding what to change
How to Import SQL and Generate an ERD in SQL Designer
- 1. Copy your SQL script — export a
CREATE TABLEDDL from your database client (MySQL Workbench, DBeaver, pgAdmin,mysqldump,pg_dump, etc.). - 2. Open SQL Designer — create a free account and start a new diagram.
- 3. Use the Import function — paste your SQL script into the import dialog. SQL Designer parses the statements and renders the schema on the canvas.
- 4. Review the diagram — tables, columns, types, constraints, and foreign key relationships are drawn automatically. Reposition tables as needed to improve readability.
- 5. Export or share — export updated SQL, share a read-only link, or embed the diagram in your documentation.
What SQL Is Supported?
SQL Designer supports standard MySQL and PostgreSQL CREATE TABLE syntax, including:
- Column definitions with data types and lengths
PRIMARY KEYdeclarations (inline and table-level)UNIQUEandNOT NULLconstraintsFOREIGN KEY ... REFERENCESclauses — rendered as relationship linesAUTO_INCREMENT(MySQL) andSERIAL/GENERATED ALWAYS AS IDENTITY(PostgreSQL)
SQL to ERD vs. ERD to SQL
SQL Designer supports both directions of the workflow:
- ERD to SQL — design your schema visually on the canvas, then export a
CREATE TABLEscript. The standard forward-engineering workflow. - SQL to ERD — paste an existing SQL script, get a visual diagram automatically. Reverse-engineering an existing schema.
Both workflows use the same free account with no diagram limits. Once a schema is imported, you can continue editing it visually and re-export updated SQL at any point.
Generate an ERD from your SQL script
Import a CREATE TABLE script into SQL Designer and get a visual ER diagram instantly — free, no install, no subscription required.
Create a Free Account