FREE TOOL
ER Diagram Generator from SQL
Paste CREATE TABLE statements and get a live ER diagram (ERD) with keys and relationships.
Live Mermaid ER preview, SVG/PNG export, and shareable links in your browser. Optional AI docs for a full data-model writeup. No account needed for the diagram.
Try the general Mermaid editorTired of redrawing ER diagrams after every migration? Export free above · connect a repo when you want Moxie Docs to keep it accurate
Paste Postgres, MySQL, or SQLite CREATE TABLE statements and get a Mermaid erDiagram with relationships and keys.
Download clean SVG or PNG for docs and slides, or copy Mermaid into a README. Shareable links too.
Optional: turn the same schema into Markdown documentation - overview, tables, and relationships.
SQL parsing and diagram rendering run in your browser. Schema never leaves your device unless you ask for AI docs.
How to generate an ER diagram from SQL
- 1. Export your schema as SQL
Run pg_dump --schema-only, mysqldump --no-data, or sqlite3 .schema, or copy CREATE TABLE statements from your migrations.
- 2. Paste the CREATE TABLE statements
Paste them into the editor above. Tables, columns, primary keys, unique keys, and foreign keys are parsed in your browser.
- 3. Check the ER diagram
Relationships come from REFERENCES clauses and FOREIGN KEY constraints. Edit the generated Mermaid if you want to rename or regroup entities.
- 4. Export the ERD
Download SVG or PNG for docs and slides, copy the Mermaid erDiagram into a README, or share a link to the diagram.
Example: SQL to ERD
Three tables with two foreign keys become a Mermaid erDiagram with one-to-many relationships between customers, orders, and order items.
SQL input
CREATE TABLE customers (
id SERIAL PRIMARY KEY,
email VARCHAR(255) NOT NULL UNIQUE
);
CREATE TABLE orders (
id SERIAL PRIMARY KEY,
customer_id INT NOT NULL REFERENCES customers(id),
total_cents INT NOT NULL,
created_at TIMESTAMP NOT NULL
);
CREATE TABLE order_items (
id SERIAL PRIMARY KEY,
order_id INT NOT NULL REFERENCES orders(id),
sku VARCHAR(64) NOT NULL,
quantity INT NOT NULL
);Generated Mermaid ER diagram
erDiagram
customers ||--o{ orders : "customer_id"
orders ||--o{ order_items : "order_id"
customers {
number id PK
string email UK
}
orders {
number id PK
number customer_id FK
number total_cents
datetime created_at
}
order_items {
number id PK
number order_id FK
string sku
number quantity
}
Common uses
Drop migration SQL into a shareable ER diagram for PRs and architecture reviews.
Export SVG or paste Mermaid into docs so the schema is visible without a DB client.
Use Document with AI for a Markdown writeup of tables and relationships.
Share a link with SQL and Mermaid encoded in the URL - no accounts, no uploads.
Frequently asked questions
More free developer tools
- Mermaid Diagram Editor
Private in-browser editor with instant preview, shareable URLs, and SVG export.
- README Generator
Structured README builder with live Markdown preview and shareable export.
- ADR Generator
Form-driven Architecture Decision Records with examples and clean Markdown export.
For teams that document code
Tired of redrawing ER diagrams after every migration?
Generate a diagram from SQL here. Connect GitHub when you want Moxie Docs to keep architecture and data-model docs accurate as the schema changes - with reviewable Cleanup PRs every Friday.
Export free above · connect a repo when you want Moxie Docs to keep it accurate