SQL to ER Diagram
Paste your CREATE TABLE statements to generate an interactive ER diagram
SQL Schema (CREATE TABLE)
ER Diagram
Foreign Key Relationships
📋 Mermaid ER Syntax (copy to AI tools)
erDiagram
users {
SERIAL id PK NOT NULL
}
users {
VARCHAR email NOT NULL
}
users {
VARCHAR name NOT NULL
}
users {
INTEGER ) role_id FK NOT NULL
}
users {
TIMESTAMP created_at NOT NULL
}
roles {
SERIAL id PK NOT NULL
}
roles {
VARCHAR name NOT NULL
}
posts {
SERIAL id PK NOT NULL
}
posts {
VARCHAR title NOT NULL
}
posts {
TEXT body NOT NULL
}
posts {
INTEGER author_id FK NOT NULL
}
posts {
BOOLEAN published NOT NULL
}
posts {
TIMESTAMP created_at NOT NULL
}
comments {
SERIAL id PK NOT NULL
}
comments {
INTEGER post_id FK NOT NULL
}
comments {
INTEGER ) author_id FK NOT NULL
}
comments {
TEXT body NOT NULL
}
comments {
TIMESTAMP created_at NOT NULL
}
tags {
SERIAL id PK NOT NULL
}
tags {
VARCHAR name NOT NULL
}
post_tags {
INTEGER post_id FK NOT NULL
}
post_tags {
INTEGER tag_id FK NOT NULL
}
users ||--o{ roles : "role_id"
posts ||--o{ users : "author_id"
comments ||--o{ posts : "post_id"
comments ||--o{ users : "author_id"
post_tags ||--o{ posts : "post_id"
post_tags ||--o{ tags : "tag_id"
About the SQL To Er Diagram
A CREATE TABLE script describes your schema, but understanding it - especially a schema you inherited - requires seeing it: which tables exist, what keys link them, where the joins live. An ER diagram turns DDL into a picture your whole team can read.
Paste CREATE TABLE statements and get an interactive entity-relationship diagram with primary and foreign keys mapped automatically. Export as Mermaid to drop the diagram into docs, PRs, or an AI assistant. Parsing happens client-side - proprietary schemas never leave your machine.
How to use
- Paste your CREATE TABLE statements (one or many).
- The diagram renders with tables as nodes and foreign keys as edges.
- Inspect any relationship by selecting a table.
- Export as Mermaid for docs, GitHub markdown, or AI tools.
Frequently Asked Questions
Which SQL dialects can I paste? ▾
Standard CREATE TABLE syntax works - PostgreSQL, MySQL, SQLite, and SQL Server definitions all parse. Dialect-specific types are shown as declared; relationships come from FOREIGN KEY ... REFERENCES clauses.
Can I export the diagram? ▾
Yes, as Mermaid code. Mermaid renders natively in GitHub markdown, Notion, Obsidian, and most documentation tools, so the diagram stays maintainable alongside your schema.