SQL to ER Diagram
Home › Django

Django to ER Diagram

Visualize your Django models as an interactive ER diagram. Django can print the exact SQL for your models — paste that and every table, column and foreign key is drawn for you.

Open the diagram tool →
No signup · nothing uploaded · export PNG / SVG / Mermaid / DBML · shareable link

How it works

  1. Print the SQL for a migration: python manage.py sqlmigrate yourapp 0001.
  2. Copy the CREATE TABLE / foreign-key statements.
  3. Paste them into the editor — the SQL is parsed automatically.
  4. Arrange, hide tables, then export PNG/SVG or convert to Mermaid/DBML.

Example

Django’s sqlmigrate emits SQL like this from your models:

CREATE TABLE "blog_author" (
  "id" bigint NOT NULL PRIMARY KEY,
  "name" varchar(100) NOT NULL
);

CREATE TABLE "blog_post" (
  "id" bigint NOT NULL PRIMARY KEY,
  "author_id" bigint NOT NULL REFERENCES "blog_author"("id")
);

…renders two tables with a relation from blog_post.author_idblog_author.id. Try it with your own →

Guide

Django doesn't have a schema file to paste — your models live in Python — but it can print the exact SQL it will run, and that's what you paste here. Run python manage.py sqlmigrate yourapp 0001 for the initial migration (or sqlmigrate on whichever migration created the tables you care about) and copy the output: CREATE TABLE "blog_post" with an REFERENCES "blog_author"("id") foreign key, ready to diagram.

Tips for multi-app projects:

The result reflects the real database Django creates — including the id BIGINT PRIMARY KEY auto-pk and _id column naming — so it's accurate even when your models use custom db_table or related_name tricks.

Why use it

DjangoSQLSQLAlchemyPostgreSQL

FAQ

How do I make an ER diagram from Django models?

Run python manage.py sqlmigrate yourapp 0001 to print the SQL, then paste the CREATE TABLE statements here. Foreign keys become relations automatically.

Can I see all apps at once?

Run sqlmigrate for each app’s migrations (or use sqlall-style output) and paste them together — tables across apps are linked by their foreign keys.

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