SQL to ER Diagram
Home › DDL to ER Diagram

DDL to ER Diagram

Paste your database DDL — the CREATE TABLE and ALTER TABLE statements that define your schema — and get an interactive ER diagram with every table, column and foreign key drawn automatically.

Open the diagram tool →
No signup · nothing uploaded · export PNG / SVG / Mermaid / DBML · shareable link
ER diagram of the DDL to ER Diagram example schema: authors and books (2 tables, 1 relationship)
The DDL to ER Diagram example below, drawn by the tool: authors and books (2 tables, 1 relationship).

At a glance

What it is
SQL to ER Diagram is a free, open-source browser tool that turns SQL DDL into an interactive entity-relationship (ER) diagram.
Input
SQL DDL: CREATE TABLE and ALTER TABLE statements for PostgreSQL, MySQL, MariaDB, SQLite, SQL Server, Oracle or Snowflake.
Output
An interactive ER diagram you can rearrange, then export as PNG, SVG, Mermaid, DBML or PlantUML, or share as a link.
Cost
Free. MIT-licensed open source. No account or signup.
Privacy
Runs entirely in your browser. The schema is never uploaded, and share links carry the diagram in the URL fragment, which is not sent to a server.
Limits
It never connects to your database itself: you paste schema text, or run one read-only catalog query in your own client and paste the result. There are no accounts, so there is no real-time multi-user editing; diagrams are kept in your browser, as a saved file, or as a share link. Layout stays smooth at around 300 tables.

How it works

  1. Copy your DDL from a migration, schema dump, or your database client.
  2. Paste it into the editor — PostgreSQL, MySQL, SQLite, SQL Server, Oracle and Snowflake DDL all parse.
  3. Tables render with columns; inline REFERENCES and FOREIGN KEY constraints become relations.
  4. Arrange, hide tables, then export PNG/SVG or convert to Mermaid/DBML.

Example

DDL like this:

CREATE TABLE authors (
  id BIGINT PRIMARY KEY,
  name VARCHAR(120) NOT NULL
);

CREATE TABLE books (
  id BIGINT PRIMARY KEY,
  author_id BIGINT NOT NULL
);

ALTER TABLE books
  ADD CONSTRAINT fk_books_authors
  FOREIGN KEY (author_id) REFERENCES authors(id);

…renders two tables with a relation from books.author_id → authors.id, including the ALTER TABLE foreign key. Try it with your own →

Guide

DDL — CREATE TABLE, ALTER TABLE, ADD CONSTRAINT — is the most complete description of a schema that exists, and this page turns any dialect of it into a diagram. The reason this page exists separately from the per-database pages: real-world DDL is dialect soup. A migration folder might contain Postgres DDL; a vendor handover might include a SQL Server .sql script with GO batches; an ORM might emit SQLite-flavoured DDL. Paste any of them, or a mixture — the parser handles inline REFERENCES, named CONSTRAINT fk_… FOREIGN KEY blocks, and the ALTER TABLE-after-the-fact style that pg_dump produces.

Good sources of DDL you already have:

Statements that don't affect the diagram — CREATE INDEX, GRANT, INSERT, CREATE VIEW — are skipped without complaint, so whole dump files paste fine.

Why use it

DDLPostgreSQLMySQLOracleSQL Server

FAQ

What counts as DDL?

Data Definition Language — the CREATE TABLE, ALTER TABLE and constraint statements that define your schema. Paste them and the diagram is drawn instantly.

Does it read ALTER TABLE foreign keys?

Yes — foreign keys added via ALTER TABLE … ADD CONSTRAINT … FOREIGN KEY (as pg_dump emits) are parsed and drawn as relations.

Is my schema uploaded anywhere?

No. Everything runs locally in your browser — your schema is never uploaded to or stored on any server.

Is it free?

Yes. It is completely free and open source, with no account or sign-up required.

Related