ER Diagram Generator from SQL

Paste CREATE TABLE statements and get an entity relationship diagram with keys and relationships, as Mermaid, SVG or PNG.

Runs in your browser. Nothing is uploaded.

Diagram
Edit in Mermaid editor
Mermaid code

How to use the ER Diagram Generator from SQL

  1. Paste your CREATE TABLE statements, or open a .sql file such as a schema dump or migrations.
  2. The diagram appears with every table, its columns and the relationships between them.
  3. Untick Show columns for an overview of a large schema, or tick Only key columns to show just keys.
  4. Download the diagram as SVG or PNG, copy the Mermaid code, or open it in the Mermaid editor to adjust it.

See your database at a glance

A database schema is easier to understand as a picture than as hundreds of lines of SQL. An entity relationship diagram shows each table as a box with its columns, and draws a line wherever one table points to another. This tool reads the CREATE TABLE statements you already have and draws that diagram for you, with no database connection and no account.

What is shown

  • Tables with their columns and types, as written in your SQL.
  • Keys: primary keys are marked PK, foreign keys FK and unique columns UK. Columns declared NOT NULL are labelled, so you can see which data is required.
  • Relationships from every foreign key, labelled with the column that links them, including composite keys and foreign keys added later with ALTER TABLE.
  • Cardinality in crow’s foot notation, worked out from whether the foreign key can be empty and whether it is unique.

For large schemas, hide the columns to see only tables and relationships, or keep only key columns to focus on how everything connects.

Built on Mermaid

The diagram is written as Mermaid erDiagram code and then rendered. Copy that code into a GitHub README, a pull request or a wiki page, and it renders there too, so the documentation can live next to your migrations and stay current. Edit in Mermaid editor opens the code in the Mermaid Diagram Editor for hand-tuning, such as adding relationship names.

Export

Download a sharp SVG for documentation or a high-resolution PNG for slides and tickets. The diagram follows the site’s light or dark theme.

Private by design

Schema files can reveal a lot about a system. Everything here runs in your browser, and nothing is uploaded. To design a new table from sample data, try the SQL CREATE TABLE Generator.

Frequently asked questions

Which databases are supported?

PostgreSQL, MySQL and MariaDB, SQLite and SQL Server DDL. Quoted names with double quotes, backticks or square brackets, schema prefixes, comments, IF NOT EXISTS and table options like ENGINE=InnoDB are all understood.

How are relationships found?

From foreign keys: inline REFERENCES on a column, FOREIGN KEY (…) REFERENCES … inside the table, and ALTER TABLE … ADD FOREIGN KEY statements later in the file. Relationships that only exist by naming convention, without a foreign key, aren’t drawn.

What do the line ends mean?

Crow’s foot notation: a fork means many, a bar means one, a circle means zero is allowed. A foreign key that can be NULL is drawn as zero or one on the parent side; a foreign key that is also unique or the whole primary key becomes one-to-one.

How do I get the SQL from my database?

Export the schema only, without data: pg_dump --schema-only for PostgreSQL, mysqldump --no-data for MySQL, .schema in the SQLite shell, or “Generate Scripts” in SQL Server Management Studio.

Is my schema uploaded?

No. The SQL is read and the diagram is drawn in your browser, so table names and structure stay private.

Tutorials