Generate ER diagram

Render tables, keys, and foreign-key relationships as an entity-relationship diagram.

freeworks offlinenothing uploaded
ToolER Diagram Generator
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

Tables become entities with typed columns, primary keys, and foreign-key edges; cardinality determines one-to-one, one-to-many, or many-to-many connectors. Relationships are rendered from declared schema text rather than guessed from names.

  • Keys provide portable evidence for edges.
  • Undeclared same-name columns remain independent.

Worked example

Blog Schema
Generate an ER diagram from users and posts tables
Input
											CREATE TABLE users (
  id INTEGER PRIMARY KEY,
  name VARCHAR(100) NOT NULL
);

CREATE TABLE posts (
  id INTEGER PRIMARY KEY,
  title VARCHAR(255),
  user_id INTEGER REFERENCES users(id)
);
										
Output
												erDiagram
    users {
        INTEGER id "PK"
        VARCHAR(100) name
    }
    posts {
        INTEGER id "PK"
        VARCHAR(255) title
        INTEGER user_id "FK"
    }
    users ||--o{ posts : "user_id"
											

When to use this

Schema reviews, migration planning, and data-team documentation render ER diagrams.

Edge cases

  • Nullable foreign keys represent optional relationships.
  • Many-to-many data needs a join table.
  • A same-named column without a constraint is only a convention.

References