SQL to Mermaid ERD Converter
Paste SQL CREATE TABLE statements and get a Mermaid ERD diagram with relationships, keys, and cardinality. Perfect for GitHub READMEs, Notion, and Obsidian.
0
Tables
0
Relations
0
Columns
Tip: Include
FOREIGN KEY constraints in your SQL to auto-detect relationships. The converter supports REFERENCES inline (PostgreSQL/MySQL) and explicit CONSTRAINT ... FOREIGN KEY syntax.
erDiagram
Live Preview
Enter SQL to see the diagram preview
Need to compare two schemas?
SchemaLens diffs SQL schemas in your browser and generates migration scripts. Free for up to 15 tables.
Open SchemaLens Diff →How It Works
1. Paste SQL
Paste any CREATE TABLE dump. Supports PostgreSQL, MySQL, SQLite, SQL Server, and Oracle syntax.
2. Detect Relationships
Foreign keys are parsed into Mermaid cardinality notation: ||--o{ for one-to-many, ||--|| for one-to-one.
3. Copy & Paste
Copy the generated Mermaid code into GitHub READMEs, Notion, Obsidian, or any Markdown editor that supports Mermaid.
Supported Mermaid ERD Features
- Tables & Columns: Every table becomes a Mermaid entity with typed columns.
- Primary Keys: Marked with
PKbadge in the diagram. - Foreign Keys: Marked with
FKand drawn as relationship lines with cardinality. - Cardinality Detection: NOT NULL foreign keys become
||--o{; nullable become|o--o{. - Unique Constraints: Marked with
UKbadge when detected. - Self-Referencing: Tables with foreign keys to themselves are supported.