SQL to ER Diagram
Home › PostgreSQL

PostgreSQL to ER Diagram

Paste your PostgreSQL schema — CREATE TABLE statements or a pg_dump — and get an interactive ER diagram with every table, column and foreign key drawn for you.

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

At a glance

What it is
SQL to ER Diagram is a free, open-source browser tool that turns a PostgreSQL schema into an interactive entity-relationship (ER) diagram.
Input
PostgreSQL CREATE TABLE and ALTER TABLE statements, or the output of pg_dump --schema-only.
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. Dump the schema with pg_dump --schema-only your_db, or copy your CREATE TABLE statements.
  2. Paste it into the editor — Postgres is parsed automatically, including ALTER TABLE … ADD CONSTRAINT foreign keys.
  3. Tables render with columns and types; relations are drawn from the constraints.
  4. Arrange, hide tables, then export PNG/SVG or share a link.

Example

A PostgreSQL schema like this:

CREATE TABLE customers (
  id SERIAL PRIMARY KEY,
  email TEXT NOT NULL UNIQUE
);

CREATE TABLE orders (
  id SERIAL PRIMARY KEY,
  customer_id INTEGER NOT NULL REFERENCES customers(id)
);

…renders two tables with a relation from orders.customer_id → customers.id. Try it with your own →

Guide

Postgres is the dialect people have the most trouble diagramming, for one reason: pg_dump doesn't put foreign keys where you expect. It emits each table with ALTER TABLE ONLY orders ADD CONSTRAINT orders_customer_id_fkey FOREIGN KEY (customer_id) REFERENCES customers(id) — sometimes thousands of lines away from the CREATE TABLE. This parser collects those ALTER TABLE statements and stitches them back onto the right tables, so a full pg_dump --schema-only paste comes out complete.

Postgres features the parser understands

Only need one schema from a multi-schema database? Filter the dump first: pg_dump --schema-only --no-owner --no-privileges -n myschema your_db. The smaller paste renders faster and the diagram stays readable.

Why use it

PostgreSQLpg_dumpMySQLSQLitePrisma

FAQ

How do I turn a Postgres database into an ER diagram?

Run pg_dump --schema-only and paste the output. Tables and foreign keys (including those added via ALTER TABLE) are drawn automatically.

Does it support pg_dump?

Yes — pg_dump emits foreign keys as separate ALTER TABLE statements, which are parsed and turned into relations.

Is my schema uploaded anywhere?

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

Can I export the diagram?

Yes — export a high-resolution PNG or vector SVG, copy the schema as Mermaid, DBML or PlantUML, or share a link that encodes the whole diagram in the URL.

Is it free?

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

Related