Paste your CREATE TABLE statements and get an entity-relationship diagram instantly: primary keys, foreign keys, unique columns and crow's foot relationship lines. Drag tables into place, then download a PNG or SVG, or copy the diagram as Mermaid code. Your SQL never leaves your browser.
Last updated:
Diagram
Your diagram appears here.
Drag tables to move them, drag the background to pan, Ctrl + scroll to zoom. Click a table to highlight its relationships.
exactly one zero or one zero or many nullable foreign key
Advertisement
Advertisement
How to use the SQL to ER Diagram
Paste your SQL: one or more CREATE TABLE statements, or open a .sql dump file. Use the sample menu to see examples.
Check the summary under the editor: it counts tables, columns and relationships and lists anything it could not resolve.
Arrange the diagram: drag tables, drag the background to pan, and use Fit or Ctrl + scroll to zoom. Click a table to highlight its links.
Adjust the display: hide data types, show only key columns or mark nullable columns.
Download PNG or SVG for docs and slides, or copy the Mermaid code to paste into Markdown, GitHub or a wiki.
What an ER diagram shows
An entity-relationship diagram (ERD) draws each table as a box listing its columns, and connects tables wherever a foreign key in one table points to a key in another. It is the fastest way to understand an unfamiliar database, review a schema change or document a project. This tool builds a physical ERD: it shows the real table and column names and data types exactly as they appear in your DDL.
In your SQL
In the diagram
id INT PRIMARY KEY or PRIMARY KEY (a, b)
PK badge, underlined column name
customer_id INT REFERENCES customers(id)
FK badge and a line to customers
email VARCHAR(255) UNIQUE
UQ badge
Foreign key column is NOT NULL
Solid line, "exactly one" at the parent end
Foreign key column allows NULL
Dashed line, "zero or one" at the parent end
Foreign key column is also UNIQUE (or the whole PK)
One-to-one: "zero or one" at the child end
Ordinary foreign key
One-to-many: crow's foot at the child end
Table referencing itself (parent_id)
A loop on the right side of the table
Getting the CREATE TABLE script from your database
Database
Command (schema only, no data)
MySQL / MariaDB
mysqldump --no-data -u user -p dbname > schema.sql
Use the generated structure.sql, sqlmigrate output or prisma migrate diff --script
Tips for a readable diagram
Declare your foreign keys. Links are drawn only from REFERENCES constraints, which is also what keeps your data consistent.
Use "Key columns only" for large schemas: the boxes shrink to the PK and FK columns, so the structure stands out.
Layout logic: tables that nothing depends on sit on the left; each table is placed one column to the right of the tables it references. Drag boxes to fine-tune, and press Re-arrange to start over.
Diagram a subset by pasting only the tables you care about; references to missing tables are listed as warnings rather than breaking the diagram.
Keep it in version control by copying the Mermaid code into a README; it re-renders whenever the schema changes.
Frequently asked questions
Which SQL dialects does the ER diagram generator support?
It reads the CREATE TABLE syntax shared by MySQL, MariaDB, PostgreSQL, SQLite and SQL Server, including backtick, double-quote and [bracket] identifiers, schema-qualified names, AUTO_INCREMENT, SERIAL, IDENTITY and table options like ENGINE=InnoDB. Statements other than CREATE TABLE and ALTER TABLE … ADD are ignored.
How are relationships detected?
From foreign keys: inline column REFERENCES clauses, FOREIGN KEY (…) REFERENCES table (…) constraints inside the table and ALTER TABLE … ADD CONSTRAINT … FOREIGN KEY statements. If a foreign key does not name the referenced columns, the parent table's primary key is used. Column names alone are never guessed, so tables without declared foreign keys appear unconnected.
How do I read the crow's foot symbols?
The end at the referenced (parent) table shows exactly one (two bars) when the foreign key column is NOT NULL, or zero or one (bar and circle) when it is nullable. The end at the child table shows zero or many (crow's foot and circle), or zero or one when the foreign key column is unique or is the whole primary key, which makes it a one-to-one link.
Can I export the diagram?
Yes. Download PNG renders the diagram at double resolution on a white background, ideal for documents and slides. Download SVG gives a scalable vector file you can edit in Inkscape, Figma or Illustrator. Copy as Mermaid produces erDiagram code that GitHub, GitLab and many wikis render in Markdown.
Can I get a diagram from an existing database?
Export the schema as SQL first, then paste it here. For example: mysqldump --no-data dbname, pg_dump --schema-only dbname, sqlite3 file.db .schema, or Script Database as CREATE in SQL Server Management Studio. Only the table definitions are needed, not the data.
Is my database schema uploaded anywhere?
No. Parsing, layout and image export all run in JavaScript in your browser. The SQL you paste and your table positions are kept only in this browser's local storage so they are still there when you come back.
Why is a table shown without links even though it has an id column like user_id?
The diagram only draws relationships that are declared as foreign keys. Many schemas (and some engines like MyISAM) skip foreign key constraints. Add a REFERENCES clause or an ALTER TABLE … ADD FOREIGN KEY line to the pasted SQL and the link appears.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.