Free browser tool · Browser-only processing

SQL Schema Visualizer

Paste your CREATE TABLE SQL and get an instant entity-relationship diagram. Supports MySQL, PostgreSQL, Snowflake, and BigQuery — inline and table-level FOREIGN KEY constraints, self-referential keys, and junction tables all handled automatically. Export as PNG, SVG, or Mermaid code. No account needed.

  • ✓MySQL, PostgreSQL, Snowflake & BigQuery DDL
  • ✓Auto-detects FK relationships and cardinality
  • ✓Export PNG, SVG, or Mermaid code — no sign-up
SQL is parsed entirely in your browser. Nothing is uploaded to any server.
Entity-Relationship Diagram
⬡

Your ER diagram will appear here

Paste SQL on the left and click Generate Diagram

Rendering diagram…

        
DATABASE SCHEMA · TOOL GUIDE

From SQL to ER Diagram in Seconds

Paste any CREATE TABLE SQL — MySQL, PostgreSQL, Snowflake, or BigQuery — and this tool draws the entity-relationship diagram for you. This guide explains what schemas and ER diagrams are, how to read the crow's foot notation, and how to design schemas that hold up over time.

What Is a Database Schema?

A database schema defines the structure of a database: which tables it contains, what columns those tables hold, the data type of each column, and how tables connect to each other through keys. The schema is the blueprint — it describes how data is organized before any rows are inserted.

Two forms of a schema coexist in practice. The physical schema is the SQL DDL — the CREATE TABLE statements your database engine reads and enforces at every write. The logical schema (the ER diagram) shows the same structure visually, using boxes and lines rather than text. This tool converts the first form into the second.

Every schema is built from the same parts:

  • Tables represent distinct types of data: customers, orders, products, employees. Each row is one record.
  • Columns store individual properties. Each column has a name, a data type, and optional constraints.
  • Primary keys uniquely identify rows. No two rows in the same table share the same primary key value, and primary key columns cannot be null.
  • Foreign keys create relationships. When an orders table holds a customer_id column that references customers(customer_id), each order is tied to exactly one customer row.
  • Constraints (NOT NULL, UNIQUE, CHECK) are rules the database enforces at write time — not in the application layer.
amridata.com · Data Warehouse Tool Suite

What Is an ER Diagram?

An entity-relationship diagram (ER diagram or ERD) draws a database schema as a picture. Tables become rectangular boxes — called entities. Columns appear as rows inside each box, labeled with their names and data types. Lines between boxes show which tables reference each other through foreign keys.

The symbols at the ends of those lines indicate cardinality: how many records on each side of a relationship are allowed or required. The notation most software developers use is crow's foot notation, named for the three-line symbol meaning "many." A single perpendicular bar means "exactly one." A small circle means "zero or more." Combined symbols express the full range: one-to-one, one-to-many, mandatory, optional.

ER diagrams turn up in pull request descriptions for schema changes, technical design documents, database onboarding guides for new engineers, and university database courses. They answer the same question every time: which tables exist, what do they store, and how do they relate?

The terms schema diagram, database diagram, and ER diagram are used interchangeably in developer conversations. This tool generates a crow's foot ER diagram from your CREATE TABLE SQL — no manual drawing, no rewriting in a custom syntax, no account required.

For analytical database design, the Star Schema Designer builds star and snowflake schemas optimized for data warehouses on Snowflake, BigQuery, and Redshift. See all free data tools for the complete collection.

How to Create an ER Diagram from SQL

You can generate an ER diagram from your existing CREATE TABLE SQL without rewriting anything in a custom syntax.

  1. Gather your SQL DDL. Collect your CREATE TABLE statements from migration files (Flyway, Liquibase, Alembic), a schema dump (pg_dump --schema-only for PostgreSQL, mysqldump --no-data for MySQL), ORM-generated schema files (Django sqlmigrate output, Rails schema.rb), or SQL you've written directly in Snowflake or BigQuery.
  2. Paste the SQL into the input panel. Copy your CREATE TABLE blocks and paste them into the SQL input above. Multiple tables in a single paste work fine — the parser handles all of them in one pass, detecting relationships across tables.
  3. Select your SQL dialect (optional). Pick PostgreSQL, MySQL, Snowflake, or BigQuery from the dropdown, or leave it on Auto-detect. The parser reads syntax signals in the SQL to identify the dialect automatically: SERIAL signals PostgreSQL; AUTO_INCREMENT signals MySQL; NUMBER(38,0) signals Snowflake; INT64 signals BigQuery.
  4. Click Generate Diagram. The parser extracts tables, columns, primary keys, and foreign key relationships, then renders a crow's foot ER diagram on the right. Junction tables (those that resolve many-to-many relationships) are detected and labeled automatically.
  5. Export. Download the diagram as a PNG for Confluence, Slack, or presentations. Download as SVG for vector-quality output in design tools. Copy the Mermaid code block to embed directly in a GitHub README, Notion page, or GitLab wiki — all three render Mermaid natively without an image upload.
No relationships showing up? The parser detects relationships from REFERENCES clauses (inline or as table-level FOREIGN KEY constraints). If your DDL omits these, the tool shows the entities but cannot infer connections. Add REFERENCES table(column) to your FK columns and regenerate.

How to Read an ER Diagram — Crow's Foot Notation

Crow's foot notation uses a small set of symbols at the ends of relationship lines. Each end of a line tells you something about the table it touches. Reading from one entity toward the other gives you a plain-English sentence about the relationship.

|
Single bar
Exactly one (mandatory)
o
Circle
Zero (optional)
<
Crow's foot
Many records
||
Double bar
Exactly one, mandatory
o|
Zero or one
Optional, one maximum
|<
One or many
Mandatory, many allowed

Reading relationship lines in practice

customers ||--o{ orders

Start at customers: "One customer…" Read the symbol nearest orders — the circle plus crow's foot means "zero or many." Full sentence: "One customer has zero or many orders." Reverse: each order belongs to exactly one customer (the double bar on the customers end).

orders ||--|{ order_items

"One order has one or many order items." The |{ end is mandatory — an order must have at least one item. This is different from the previous example where the circle allowed zero.

Self-referential: categories o|--o{ categories

A category can have zero or one parent category. A category can be the parent of many sub-categories. Self-referential relationships show up in tree structures: product categories, comment threads, organizational charts.

Many-to-many (via junction table): When you see a table with two foreign key columns and no other significant data columns, it resolves a many-to-many relationship. For example, post_tags connecting posts and tags means one post can have many tags, and one tag can belong to many posts. The tool labels these junction tables automatically.

Reading tip: Always read from one entity, then read the symbol at the far end of the line. That symbol tells you how many records on the other side can exist for one record on yours.

Common Database Relationships Explained

One-to-one (||--||)

One row in Table A matches exactly one row in Table B. These are uncommon in normalized databases. They appear when you need to split a table with many columns (separating user profile data from authentication credentials) or when sensitive fields belong in a separately secured table.

-- One-to-one: users → user_profiles
CREATE TABLE users (
  user_id  SERIAL PRIMARY KEY,
  email    VARCHAR(255) NOT NULL UNIQUE
);
CREATE TABLE user_profiles (
  profile_id  SERIAL PRIMARY KEY,
  user_id     INT NOT NULL UNIQUE REFERENCES users(user_id),
  bio         TEXT
);

One-to-many (||--o{)

The most common pattern. One row in Table A relates to many rows in Table B. The foreign key lives on the "many" side. Examples: one customer has many orders; one author has many posts; one department has many employees. If the FK column is NOT NULL, the relationship is mandatory (the child row must have a parent).

Many-to-many (via junction table)

Many rows in Table A can relate to many rows in Table B. Because relational databases cannot express this directly, a junction table (also called an associative or bridge table) stores the associations. The junction table has at least two FK columns, one pointing to each side. It often carries additional data about the relationship: a quantity, a role, a date assigned.

-- Many-to-many: employees ↔ projects
CREATE TABLE employee_projects (
  employee_id  INT NOT NULL REFERENCES employees(employee_id),
  project_id   INT NOT NULL REFERENCES projects(project_id),
  role         VARCHAR(100),
  PRIMARY KEY (employee_id, project_id)
);

Self-referential

A table with a foreign key pointing at its own primary key. The classic examples: employees.manager_id REFERENCES employees(employee_id), categories.parent_id REFERENCES categories(category_id), and comments.parent_comment_id REFERENCES comments(comment_id). These create a hierarchy. Each row can optionally point to another row in the same table as its parent.

Supported SQL Dialects: MySQL, PostgreSQL, Snowflake, BigQuery

MySQL PostgreSQL Snowflake BigQuery

PostgreSQL

PostgreSQL-specific types are handled: SERIAL and BIGSERIAL (auto-incrementing integers), TIMESTAMPTZ, UUID, JSONB, ARRAY, and TEXT. Both inline REFERENCES and named constraint syntax (CONSTRAINT fk_name FOREIGN KEY) are parsed. Schema-qualified table names like public.customers are accepted with the schema prefix stripped from the diagram.

MySQL

MySQL differences are handled: AUTO_INCREMENT, ENGINE=InnoDB (stripped for diagram purposes), backtick-quoted identifiers, TINYINT(1) (treated as bool), ENUM types (shown as the enum type), and KEY/INDEX statements (skipped). MySQL's convention of defining foreign keys as separate KEY entries followed by CONSTRAINT blocks is supported.

Snowflake

Snowflake-specific types are normalized: NUMBER(38,0) becomes bigint, VARCHAR(16777216) becomes varchar. AUTOINCREMENT and IDENTITY modifiers are recognized. VARIANT, OBJECT, and ARRAY types are passed through. Clustering keys (CLUSTER BY) are parsed without error but are not represented in the diagram.

BigQuery

BigQuery standard SQL DDL types are parsed: INT64, FLOAT64, NUMERIC, BIGNUMERIC, STRING, BYTES, BOOL, DATE, DATETIME, TIMESTAMP, JSON, ARRAY<type>, STRUCT<...>. Note that BigQuery's FOREIGN KEY constraints are declarative — the database does not enforce them at write time. The tool renders them as relationships and flags them in the junction note.

Database Schema Design Best Practices

Use surrogate primary keys

Use auto-incrementing integers or UUIDs as primary keys, not natural identifiers like email addresses, product codes, or phone numbers. Natural keys change over time, and changing a primary key cascades through every foreign key that references it. Surrogate keys never need to change.

Name foreign key columns consistently

A foreign key column should follow the pattern {referenced_table_singular}_id. Every column named customer_id in your schema is a foreign key to the customers table. This convention makes relationships readable from column names alone — no need to hunt through DDL for REFERENCES clauses.

Add created_at to every table

That column costs nothing at design time and becomes essential the moment you need to debug data, understand growth patterns, or answer "when did this record appear?" questions. DEFAULT NOW() handles the insertion automatically.

Normalize to 3NF for transactional databases

Third Normal Form removes redundancy: every non-key column depends only on the primary key, not on other non-key columns. If the same value appears in multiple rows — a customer's city name, a product category label — it probably belongs in its own table with a foreign key reference.

Use VARCHAR with explicit length limits

TEXT stores unlimited characters with no enforcement. VARCHAR(255) both constrains input and communicates intent to the next developer. Use the smallest practical length: CHAR(2) for country codes, VARCHAR(100) for names, VARCHAR(500) for URLs, TEXT only for genuinely unbounded content.

Apply NOT NULL explicitly

Mark columns NOT NULL when they should always have a value. The database enforces this at every insert or update, catching bugs at the data layer rather than the application layer. It also signals intent to everyone reading the schema later.

Name foreign key constraints explicitly

CONSTRAINT fk_orders_customers FOREIGN KEY (customer_id) REFERENCES customers(id) produces error messages like "violates foreign key constraint fk_orders_customers" — immediately clear about which relationship failed, rather than the auto-generated name PostgreSQL assigns (orders_customer_id_fkey).

Test queries against the schema before shipping it

Write out the three to five most common queries the schema will serve before finalizing column placement and table boundaries. If a frequent query requires five or more joins, consider whether a summary table or materialized view belongs in the design. See the Star Schema Designer for structuring analytical schemas specifically for read-heavy workloads.

Frequently Asked Questions

What is the best free ER diagram tool?

For generating an ER diagram from existing CREATE TABLE SQL, this visualizer is the only free tool that accepts standard SQL DDL from MySQL, PostgreSQL, Snowflake, and BigQuery with no account required. For manual diagram creation, draw.io (diagrams.net) is free and capable. For teams wanting a persistent workspace, dbdiagram.io's free tier works well — though it requires DBML syntax rather than standard SQL, so you'll need to rewrite your DDL.

Can I create an ER diagram from an existing database?

Yes. Export the DDL from your database client first. In PostgreSQL: pg_dump --schema-only -n public mydb > schema.sql. In MySQL: mysqldump --no-data mydb > schema.sql. In Snowflake: SELECT GET_DDL('TABLE', 'MYDB.MYSCHEMA.MYTABLE') for each table. Then paste the output here.

What is the difference between an ER diagram and a database schema?

A database schema is the formal, enforceable SQL definition of a database's structure — the CREATE TABLE statements your database reads and validates against. An ER diagram is the visual representation of that same structure, designed for human readability. This tool converts one into the other: input your SQL DDL, get back your ER diagram.

What is a primary key?

A primary key is a column (or combination of columns) that uniquely identifies each row in a table. No two rows can share the same primary key value, and primary key columns cannot be null. In this tool's ER diagrams, primary key columns are marked PK in the entity box.

What is a foreign key?

A foreign key is a column in one table that references the primary key of another table, creating a link between the two rows. The database enforces referential integrity: a foreign key value must exist in the referenced table (or be null if the column allows it). In the ER diagram, foreign key columns are marked FK and connected by a relationship line to the referenced table.

What is a junction table?

A junction table (also called an associative table or bridge table) resolves a many-to-many relationship between two tables. It has at least two foreign key columns, one referencing each of the two related tables. order_items connecting orders and products is a classic example. The tool detects junction tables automatically and labels them in the diagram.

Why doesn't my BigQuery schema show foreign key relationships?

BigQuery's DDL supports FOREIGN KEY and REFERENCES syntax, but BigQuery does not enforce these constraints — they are declarative and informational only. Many BigQuery schemas are created without any FK declarations at all. If your schema lacks REFERENCES clauses, the tool cannot infer relationships from the SQL alone. Add them to your DDL and regenerate.

Can I export the ER diagram to include in documentation?

Yes. PNG works for Confluence, Notion, Slack, presentations, and anywhere that accepts image uploads. SVG gives vector-quality output for design tools or print. The Mermaid code block pastes directly into GitHub README files, GitLab wikis, and any Notion or Confluence page — those platforms render it natively without an image.

Does the tool support schemas with many tables?

The tool handles schemas with up to around 100–150 tables reliably. For very large schemas, the auto-layout can get dense. Paste a subset of related tables (one domain at a time) for more readable diagrams on complex systems.

What is the difference between this tool and the Star Schema Designer?

This SQL Schema Visualizer generates ER diagrams from any existing CREATE TABLE SQL — transactional (OLTP) or analytical. The Star Schema Designer is a purpose-built tool for designing data warehouse schemas: fact tables, dimension tables, and the star or snowflake patterns optimized for Snowflake, BigQuery, and Redshift. If you're documenting an existing schema, use this tool. If you're designing a new analytical schema from scratch, start with the Star Schema Designer.

When this tool is useful

Paste your SQL. See your schema.

This tool is fastest when you already have CREATE TABLE SQL and need to explain, review, or document the schema visually — without installing desktop software or signing up for a service. It works for any relational schema: transactional databases, data warehouse staging layers, and application backends.

Mapping an unfamiliar databaseReviewing schema migrationsREADME and wiki diagramsDatabase coursework
FAQ

SQL Schema Visualizer questions

How the free browser tool works.

Which SQL dialects are supported?+

MySQL, PostgreSQL, Snowflake and BigQuery. Auto-detect picks one from the syntax, and you can override it.

Can I paste pg_dump or mysqldump output?+

Yes. Comments and non-table statements are skipped, and only CREATE TABLE blocks are drawn.

How do I put the diagram in a GitHub README?+

Copy the Mermaid code and paste it into a mermaid code fence. GitHub renders it without an image file.

Is my schema sent to a server?+

No. Parsing runs in your browser. The page loads the Mermaid.js library from a CDN on first use, and no schema data is sent with that request.