Skip to content
Visualization

SQL to ER Diagram

Parse CREATE TABLE statements and automatically generate ER diagrams in Mermaid format. Securely visualize your DB design entirely within the browser.

Guide: How to use & features

  • Enter or paste SQL `CREATE TABLE` statements into the text area.
  • Click the "Visualize" button to generate and display the ER diagram using Mermaid syntax.
  • Table relationships (Foreign Keys) are automatically extracted from `FOREIGN KEY` or `REFERENCES` clauses.
  • Use the "Copy Mermaid Code" button to save the generated syntax to your clipboard.
  • Your schema data is processed entirely in the browser, ensuring privacy and security.

Samples: Examples

Users and Posts (One-to-Many)

Input

CREATE TABLE users (
  id INT PRIMARY KEY,
  name VARCHAR(50)
);

CREATE TABLE posts (
  id INT PRIMARY KEY,
  user_id INT REFERENCES users(id),
  title VARCHAR(100)
);

Output

erDiagram
    users {
        INT id PK
        VARCHAR(50) name
    }
    posts {
        INT id PK
        INT user_id
        VARCHAR(100) title
    }

    posts }|--|| users : "user_id -> id"

FAQ: FAQ

  • Does it support all SQL dialects?

    It supports standard SQL CREATE TABLE syntax. Some highly specific proprietary vendor extensions may not be fully parsed as it uses a custom regex-based parser.
  • Is my data sent to a server?

    No. All processing is done locally in your browser via JavaScript. Your SQL code never leaves your computer.
  • What if relationships are not showing up?

    Ensure that your statements include FOREIGN KEY or REFERENCES clauses. The tool relies on these constraints to identify and draw relationships.

Use cases: Common Use Cases

  • Database Documentation

    Quickly visualize and document existing table structures by pasting SQL exports.

  • Schema Design Verification

    Self-check your DDL to ensure that relationships and constraints are correctly defined during the design phase.

  • Team Collaboration

    Share specific sub-system structures with your team using lightweight Mermaid syntax before generating full documentation.

Notes: Notes & Limitations

  • Limited SQL Syntax

    Statements other than CREATE TABLE (e.g., stored procedures, triggers, complex INDEX definitions) are ignored.

  • Performance with Large Schemas

    Very large schemas with dozens of tables may significantly impact browser rendering performance.

  • Syntax Errors

    Incomplete or malformed SQL statements (missing parentheses, typos) will result in parsing failures.

erDiagram USERS ||--o{ POSTS : "user_id -> id" USERS { int id PK string name } POSTS { int id PK int user_id string title }

About the SQL to ER Diagram (Mermaid) Generator

This online tool automatically generates Entity-Relationship (ER) diagrams in Mermaid.js format directly from your SQL DDL statements (CREATE TABLE).
Visualizing schemas directly from your database definitions dramatically improves efficiency during database design reviews and documentation creation.

How It Works & Privacy

This tool runs entirely in your browser using JavaScript. The SQL statements you input, including table structures and foreign key relationships, are never transmitted to any external servers.
You can safely use it to visualize the most sensitive internal database schemas without any risk of information exposure.

Articles for this tool

Recent Articles

Use Case
2026-08-04

CREATE TABLE Reference: MySQL vs PostgreSQL vs SQLite Types & Constraints

A cross-database CREATE TABLE (DDL) reference with cheat sheets for data types, auto-increment keys (AUTO_INCREMENT / IDENTITY / rowid), foreign key ON DELETE behavior, and the CHECK constraint that MySQL silently ignores.

Introduction
2026-08-03

How CREATE TABLE Generation From a Visual Table Design Works | DDL Builder

A look inside DDL Builder, which turns a visually designed table into CREATE TABLE statements and an ER diagram. Covers the MySQL/PostgreSQL/SQLite type-mapping rules and the column-inference algorithm used for JSON samples.

Use Case
2026-07-21

GitHub Actions needs Design Patterns: Speed Up CI, Avoid the Anti-Patterns

A pattern reference for GitHub Actions job dependencies (needs). Covers diamond-shaped fan-out, concurrency cancellation, fail-fast tradeoffs, matrix-plus-needs gotchas, and reusable workflows, with copy-paste YAML examples.

Use Case
2026-07-21

SQL JOIN Types: Complete Reference to INNER, LEFT, RIGHT & FULL

A reference for SQL JOIN types (INNER/LEFT/RIGHT/FULL/CROSS/SELF) with a cheat sheet and row-count walkthroughs. Covers why one-to-many joins duplicate rows, the WHERE-vs-ON NULL trap, and how to write multi-table joins.

Introduction
2026-07-16

Case Converter: camelCase, snake_case & kebab-case — 9 Styles at Once

Convert identifiers between camelCase, PascalCase, snake_case, CONSTANT_CASE, kebab-case and more — all nine styles side by side. Handles acronym runs like HTTPServer, digits, and bulk multi-line conversion.

Introduction
2026-07-16

LLM API Cost Calculator: Compare Claude, GPT & Gemini Pricing Side by Side

Paste a prompt, set the expected output tokens, and compare per-request API costs across Claude, GPT and Gemini models. Covers input/output pricing structure, auto-updated price tables, and estimate limits.

Ad

Ad