Django to ER Diagram
Visualize your Django models as an interactive ER diagram. Paste models.py as it is — fields, ForeignKey, OneToOneField, ManyToManyField and abstract base models are read directly — or paste the SQL from sqlmigrate for the exact database tables.
At a glance
- What it is
- SQL to ER Diagram is a free, open-source browser tool that turns Django models into an interactive entity-relationship (ER) diagram.
- Input
- A Django
models.py(fields,ForeignKey,OneToOneField,ManyToManyField, abstract base models), or the SQL thatsqlmigrateprints. - 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
- Copy your
models.py— one app or several pasted together. - Paste it into the editor (or drop the
.pyfile on the page). Django is detected automatically. - Each model becomes a table with Django’s implicit
id;ForeignKeyandOneToOneFieldbecome foreign keys andManyToManyFieldbecomes a junction table. - Arrange, hide tables, then export PNG/SVG or convert to Mermaid/DBML.
Example
Paste Django models like these:
from django.db import models
class Author(models.Model):
name = models.CharField(max_length=100)
class Post(models.Model):
title = models.CharField(max_length=200)
author = models.ForeignKey(Author, on_delete=models.CASCADE)
…and you get Author and Post with a relation from Post.author_id → 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:
- Run
sqlmigrateonce per app and paste the outputs together — tables link up by their foreign keys automatically, and theappname_table prefixes keep the diagram readable. ForeignKeybecomes a drawn relation;ManyToManyFieldshows up as the auto-created join table (blog_post_tags) exactly as Django builds it.- If you use
django-extensions, thegraph_modelcommand is an alternative — but its output is static dot/PyGraphviz, while this renders interactive and exportable.
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
- Private: everything runs in your browser — nothing is uploaded or stored on a server.
- Straight from code: no migration run and no database needed —
models.pyis read as it is. - Interactive: drag tables, auto-arrange, hide noise, add notes, and manually link columns.
- Export a high-res PNG, vector SVG, or the schema as Mermaid / DBML / PlantUML code.
- Free & open source — no account, no sign-up.
FAQ
How do I make an ER diagram from Django models?
Paste your models.py into the editor. Each model becomes a table, and ForeignKey, OneToOneField and ManyToManyField become relations.
Can I see all apps at once?
Yes. Paste the models from several apps together — relations written as "app.Model" are linked by the model name.
Are the table names the real database names?
A model that sets db_table in its Meta is shown under that name. Otherwise the table is labelled with the model class name (Post), because Django’s default app_post name depends on the app label, which models.py doesn’t contain. For the exact tables, paste the output of python manage.py sqlmigrate yourapp 0001 instead.
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.