SQL DDL to ER Diagram — Visualize Tables & Relationships
Paste CREATE TABLE statements and instantly generate an interactive entity-relationship diagram. Primary keys, foreign keys, and relationships are detected automatically. Export to SVG, PNG, or Mermaid syntax. Everything runs locally — your schema never leaves the browser.
Paste SQL DDL on the left and click Generate Diagram to visualize your schema.
- No warnings yet. Generate a diagram first.
What This Tool Does
The DDL to ER Diagram tool takes SQL CREATE TABLE statements — the Data Definition Language that defines your database schema — and produces a visual entity-relationship diagram showing how tables connect. It parses primary keys, foreign keys, column types, and nullable constraints to build an accurate model of your schema.
Supported DDL Patterns
CREATE TABLE TableName (...)with schema-qualified names likedbo.Ordersor"sales"."invoice"- Inline primary keys:
id INT PRIMARY KEY - Table-level constraints:
PRIMARY KEY (col1, col2)including composite keys - Foreign keys:
FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID)with optionalCONSTRAINTnames - Bracket and double-quote identifiers:
[Table],"column" - SQL comments: single-line
--and block/* ... */
Relationship Detection
The parser identifies three categories of relationships:
| Pattern | Detection | Diagram Notation |
|---|---|---|
| One-to-Many | Standard FOREIGN KEY referencing another table's PRIMARY KEY | Parent ──┤ Child (crow's foot) |
| Many-to-Many | Join table with composite PK of exactly two FK columns pointing to different tables | Table A ┤──├ Table B (via join table) |
| Self-Reference | FOREIGN KEY referencing the same table (e.g., Employee → Manager) | Curved arrow back to same table |
Export Formats
SVG — Scalable Vector
Lossless vector format. Ideal for documentation, wikis, and presentations. SVG files stay crisp at any zoom level and can be edited in tools like Figma, Illustrator, or Inkscape.
PNG — Raster Image
Pixel-based export at 2× resolution. Best for embedding in Slack messages, Confluence pages, emails, and README files where an image tag is simpler than inline SVG.
Mermaid Syntax
Text-based ER diagram markup compatible with Mermaid.js. Renders automatically in GitHub README files, Notion, GitLab wikis, Obsidian, and many other platforms. Paste the generated syntax into a ```mermaid code fence and the diagram renders inline.
🔒 Your Schema Stays on Your Machine
Database schemas contain table names, column names, and relationship structures that reveal your application's data architecture. This tool processes everything in your browser's JavaScript engine — your DDL never leaves your device, is never transmitted to any server, and is never logged.
You can verify this by opening your browser's Network panel (F12 → Network) and observing that no requests contain your SQL input.
