SQL to ERD Generator
A database diagram from SQL: drop in your DDL and watch the tables, keys and foreign-key links redraw as you type.
Paste your SQL CREATE TABLE statements and this ERD generator draws the entity-relationship diagram for you. It reads each table's columns and types, flags primary and foreign keys, and follows every FOREIGN KEY / REFERENCES constraint to connect the tables with crow's-foot relationship lines. The diagram is built with Mermaid, so you can grab the picture as SVG or PNG for your docs, or copy the Mermaid source to keep in a README. Everything parses and renders in your browser.
How it works
- 1
Paste your CREATE TABLE DDL
Put one or more CREATE TABLE statements in the left editor — MySQL, PostgreSQL, SQLite or SQL Server dialects all parse. Inline REFERENCES and separate FOREIGN KEY constraints are both understood.
- 2
Read the diagram
The right pane draws each table as an entity box listing its columns and types, with PK and FK tags, and joins related tables with a one-to-many crow's-foot line labelled by the foreign-key column.
- 3
Export or copy the source
Download the ERD as SVG or PNG for documentation, or hit Copy Mermaid to lift the erDiagram source into a Markdown file, wiki, or a Mermaid live editor.
Instant & 100% private — nothing is uploaded
Everything runs locally in your browser. Your code, text and files are processed on your own device and are never sent to a server — so there are no upload waits, no size limits from us, and nothing is ever stored or logged.
Frequently asked questions
- What SQL do I paste to get a diagram?
- Standard DDL. For example, CREATE TABLE users (id INT PRIMARY KEY, email VARCHAR(255)); CREATE TABLE orders (id INT PRIMARY KEY, user_id INT, FOREIGN KEY (user_id) REFERENCES users(id)); draws a users box and an orders box joined by a users ||--o{ orders line, with user_id tagged FK.
- How does it detect relationships between tables?
- It looks for foreign keys — both the inline form (user_id INT REFERENCES users(id)) and the table-level form (FOREIGN KEY (user_id) REFERENCES users(id)), including named CONSTRAINT ... FOREIGN KEY clauses. Each one becomes a one-to-many link from the referenced table to the referencing table.
- Can I get the Mermaid source instead of just an image?
- Yes. The Copy Mermaid button gives you the erDiagram text the tool generated, so you can paste it into GitHub Markdown, Notion, Obsidian, or the Mermaid live editor and keep editing the schema diagram by hand.
- Which databases and column types work?
- It's dialect-agnostic parsing, so PostgreSQL, MySQL, MariaDB, SQLite and SQL Server DDL all work. Types like VARCHAR(255) and DECIMAL(10,2) are kept on each column, composite primary keys are marked, and CREATE TABLE IF NOT EXISTS plus trailing options like ENGINE=InnoDB are ignored.
More tools
More from the Hivly network
Free sister tools on our other sites.