SQL to ER Diagram

Visualize your database schema from CREATE TABLE statements

SQL Input

Load sample schema:

ER Diagram

0 tables

Your ER diagram will appear here

Paste SQL and click Generate

Mermaid Code

erDiagram
    %% Generated Mermaid code will appear here

SQL to ER Diagram: Visualize Your Database Schema Instantly

Understanding database relationships is crucial for developers, DBAs, and architects. Our SQL to ER Diagram tool takes your CREATE TABLE statements and generates a visual Entity-Relationship diagram using Mermaid.js—all in your browser, with no data sent to any server.

How It Works

  1. Paste your SQL - Enter one or more CREATE TABLE statements
  2. Click Generate - The tool parses tables, columns, and foreign keys
  3. View the diagram - See relationships rendered as an ER diagram
  4. Copy Mermaid code - Use in documentation, README files, or Mermaid-enabled tools

Supported SQL Features

Table Parsing

  • • CREATE TABLE statements
  • • Column names and types
  • • Backtick and quote handling

Constraint Detection

  • • PRIMARY KEY indicators
  • • FOREIGN KEY relationships
  • • UNIQUE constraints

Understanding the Diagram

SymbolMeaning
||--o{One-to-Many relationship
||--||One-to-One relationship
PKPrimary Key
FKForeign Key

Why It's Free & Private

This tool uses Mermaid.js for client-side rendering. Your SQL never leaves your browser—there's no server processing, no data storage, and no tracking. The generated Mermaid code can be used anywhere that supports Mermaid diagrams, including GitHub, GitLab, Notion, and many documentation tools.

What if my SQL uses non-standard syntax?

The parser handles common MySQL, PostgreSQL, and SQLite syntax. It's designed to be forgiving with variations in formatting. However, very complex constraints or database-specific features may not be fully parsed. The tool focuses on extracting table names, columns, primary keys, and foreign key relationships.