SQL to ER diagram

Paste your DDL, get an ERD.

LetDraw turns SQL to ER diagram in one paste. Drop in your CREATE TABLE statements and get every table, column, primary key and foreign key laid out as editable shapes, with relationships drawn between the tables. Postgres, MySQL and standard SQL all work.

Shop schema · from SQL
users uuidtexttext idPK email name orders uuiduuidnumerictimestamptz idPK user_idFK total created_at order_items uuidint order_idFK qty
Step by step

How to turn SQL into an ER diagram

From a migration file or a schema dump to an editable diagram in under a minute.

  1. Copy your DDL

    Grab the CREATE TABLE statements from your migrations or a schema-only dump. Comments are ignored, so you can paste the file as it is.

  2. Paste it into Generate from Code

    Open Generate from Code (a Pro feature) from the More tools menu and paste. The SQL is detected automatically and a live preview appears.

  3. Pick the relationship style

    Show foreign keys as a plain line, a straight arrow, a smart routed connector or crow's foot ER notation.

  4. Insert and share

    Drop the ERD on the canvas, rearrange or annotate it, then share a link or export it as PNG, SVG or PDF.

DDL to ERD, done right

From CREATE TABLE to diagram, column by column

Each table becomes a grid with a header and one row per column, showing the type next to the name. Primary keys and foreign keys are marked, long types are shortened (timestamptz, varchar), and the tables are arranged in a tidy grid. Everything is made of normal LetDraw shapes, so every cell stays editable. While the generated ERD is unchanged, Diagram to Code gives it back as Mermaid erDiagram code.

  • Postgres, MySQL and standard SQL, including quoted names, schema prefixes and IF NOT EXISTS
  • Keys detected: PRIMARY KEY, UNIQUE, NOT NULL, inline REFERENCES and FOREIGN KEY constraints
  • Crow's foot cardinality inferred from each foreign key column (NOT NULL, UNIQUE)
Try it now
CREATE TABLE users ( id uuid PRIMARY KEY, email text UNIQUE ); CREATE TABLE orders ( id uuid PRIMARY KEY, user_id uuid NOT NULL REFERENCES users(id) ); users uuidid PK textemail orders uuidid PK uuiduser_id FK
What people use it for

Why teams turn SQL into ER diagrams

A schema is easier to discuss when everyone can see the tables and how they connect.

Onboarding new developers

Give newcomers a map of the database on day one instead of a folder of migration files.

Reviewing migrations

Paste the new tables next to the old ones and talk about the change on a shared canvas.

Docs and READMEs

Export the ERD as PNG, SVG or PDF and drop it into your docs, wiki or design notes.

Legacy schema audits

See an inherited Postgres or MySQL schema at a glance and spot the tables nothing points to.

Design reviews

Sketch a new feature's tables, generate the diagram and leave comments right on the relationships.

Teaching databases

Show students how keys and foreign keys become one-to-many relationships with crow's foot ends.

Questions

SQL to ER diagram FAQ

Which SQL can I paste?
CREATE TABLE statements in Postgres, MySQL or standard SQL. Foreign keys are read from inline REFERENCES and from FOREIGN KEY constraints inside the CREATE TABLE; relationships to tables that are not in your paste are skipped with a warning.
Is my schema uploaded anywhere?
No. The SQL is parsed and laid out in your browser. Only the diagram you insert is saved, the same way as any other drawing.
Is it free?
Generate from Code, which turns SQL into a diagram, is part of Pro and Enterprise. The Free plan still gives you the full canvas, every diagram type and export to PNG, SVG and PDF, with no credit card.
Can I edit the diagram or get code back?
Yes. Every table, cell and relationship is a normal shape you can move, restyle or delete. While the generated ERD is unchanged, Diagram to Code returns it as Mermaid erDiagram code.

Your schema, as a diagram, in one paste.

Open LetDraw, paste your CREATE TABLE statements and watch the tables and relationships appear.