How to sQL to ERD
- Paste CREATE TABLE statements into the box that opens, or open a .sql file. Schema-only dumps work best: pg_dump --schema-only, mysqldump --no-data, or “Script table as CREATE” in SQL Server Management Studio.
- Check the summary: the number of tables and relationships found, the dialect it looks like, and any notes. If something can't be parsed you'll see the exact line and the reason.
- Choose Create diagram. Tables are laid out with referenced tables above the ones that point at them. Drag, recolour or rearrange anything, then export PNG, SVG or PDF — or generate SQL for another database.
What does this tool do?
Reading a schema as text gets hard after a dozen tables. A diagram shows at a glance which tables depend on which, where the many-to-many junction tables are and which foreign keys are optional. The importer understands inline REFERENCES, table-level FOREIGN KEY constraints, ALTER TABLE … ADD CONSTRAINT added later in the script, composite primary keys, UNIQUE constraints, CREATE INDEX and CREATE UNIQUE INDEX, defaults, and auto-increment in each dialect's syntax: SERIAL and IDENTITY columns in PostgreSQL, AUTO_INCREMENT in MySQL, IDENTITY(1,1) in SQL Server and AUTOINCREMENT in SQLite.
Relationship ends are inferred from the constraints. A nullable foreign key gets an optional parent end; a foreign key that is also unique becomes one-to-one. Statements that don't describe structure — INSERT, DROP, SET, USE, views and functions — are skipped and counted, not guessed at. Everything happens in your browser, so private schemas never leave your computer.
Privacy
Everything you type is processed in your browser. Nothing you enter is sent to our servers or stored by us. There's no account to create and nothing to install.
Frequently asked questions
Which SQL dialects can it read?
PostgreSQL, MySQL and MariaDB, SQL Server (including GO batch separators and [bracketed] names) and SQLite. Mixed scripts are fine; the detected dialect is shown before you import.
What if my SQL has errors?
Problems that would produce a wrong diagram — an unclosed bracket or quote, a table with no column list, a PRIMARY KEY naming a column that doesn't exist — are reported with their line number, and you can click to jump there. You can still import the tables that parsed if you choose to.
Can I add tables from a second script?
Yes. When a diagram already exists, choose “Add to diagram” and the new tables are placed beside the current ones, renamed if a name is already taken.
Does it read my data?
No. INSERT statements are ignored, and nothing you paste is uploaded — the parser runs in your browser.
Last reviewed by the M2Toolkit team.