Make an ER diagram from your database schema with AI
An AI coding tool can read your schema and draw the ER diagram for you: every table, its columns and keys, and how the tables relate, with crow’s-foot lines. Point it at the SQL file, the Prisma schema or the migrations, ask for the diagram, and check the relationships. It reads the real schema, so you don’t retype tables into an ERD tool, and when the schema changes you ask for the update at the same link.
1. Open your AI tool
It needs to read the schema, so use a tool that works inside the repo:
Each guide has the one-minute setup. Once Diagram is connected, every diagram the AI draws is saved at a link instead of staying in the chat.
2. Ask for it
Say what you want to see in plain words. These requests work, and each is one message:
The whole database
Every table and relationship, for onboarding or a design review. Fine up to about 15 tables; past that, split it.
- “Read the schema in prisma/schema.prisma and draw an ER diagram: every table with its columns and types, primary and foreign keys, and crow’s-foot relationships. Give me a link.”
- “Draw an ER diagram of the database from the migrations in db/migrations. Use the latest state, not every step.”
From SQL you paste
No repo, just a dump or a few CREATE TABLE statements. Any AI chat can do this one.
- “Turn this SQL into an ER diagram with keys and relationships, and give me a link: (paste the CREATE TABLE statements)”
One area
The tables behind one feature, which is what most reviews need.
- “Draw just the billing tables (subscriptions, invoices, payments) and the tables they reference, as an ER diagram.”
- “Show which tables the orders service reads and writes, grouped by service.”
A change before you make it
Agree on a migration before anyone writes it.
- “Draw the ER diagram as it is now, then a second version with the teams table we discussed, and mark what changes.”
An example
3. Check it
The AI draws what it read or was told. These habits catch most mistakes:
- Say where the schema is. Name the file or folder. Otherwise the AI may draw from the models, the migrations or its own guess, and they rarely agree.
- Ask for keys and cardinality. Primary keys, foreign keys, and whether each relationship is one-to-one, one-to-many or many-to-many. That is what makes an ER diagram useful rather than a list of boxes.
- Leave out the noise. Timestamps, soft-delete columns and audit fields on every table make it twice as tall. Ask the AI to drop them or note them once.
- Check the many-to-many tables. Join tables are where drawings go wrong. Ask which tables it treated as join tables and why.
4. Share the link and keep it current
Put the link in the README, the pull request or the doc. When things change, ask for the change in plain words. It’s saved at the same link and every earlier version is kept, so nobody is looking at an old picture.
Questions
- Can AI generate an ER diagram from SQL?
- Yes. Paste the CREATE TABLE statements into any AI chat, or point a coding tool at the schema file, and ask for an ER diagram with keys and relationships. With Diagram connected it is saved at a link you can share.
- Does it work with Prisma, Django, Rails or TypeORM models?
- Yes. The AI reads the model files the same way it reads SQL. Say which file or folder holds the schema.
- Is my schema uploaded anywhere?
- Your AI tool reads it where it already runs. Only the finished diagram is saved to Diagram, private to you until you share it. A diagram that contains a credential is refused, so keep connection strings out of it.
- What notation does it use?
- Crow’s-foot by default, which most developers read. Ask for Chen or UML class notation if your team uses it.
- How do I keep it current?
- Ask the AI after a migration: “update the ER diagram, we added the teams table”. The change is saved at the same link and earlier versions are kept.