ER Diagram Generator
Paste CREATE TABLE SQL or DBML and the crow’s-foot ERD draws itself as you type, or describe your app and let AI draft it. Free, no signup.
Export the schema
Table users {
id SERIAL [pk, increment]
email VARCHAR(255) [not null, unique]
display_name VARCHAR(80)
created_at TIMESTAMP [not null, default: `now()`]
}
Table posts {
id SERIAL [pk, increment]
author_id INTEGER [not null]
title VARCHAR(200) [not null]
body TEXT
published_at TIMESTAMP
}
Table comments {
id SERIAL [pk, increment]
post_id INTEGER [not null]
user_id INTEGER
body TEXT [not null]
}
Table tags {
id SERIAL [pk, increment]
name VARCHAR(50) [not null, unique]
}
Table post_tags {
post_id INTEGER [pk]
tag_id INTEGER [pk]
}
Ref: posts.author_id > users.id
Ref: comments.post_id > posts.id
Ref: comments.user_id > users.id
Ref: post_tags.post_id > posts.id
Ref: post_tags.tag_id > tags.id
How to make an ER diagram from SQL
- Export your schema without data (
mysqldump --no-data,pg_dump --schema-only, or.schemain SQLite), or write theCREATE TABLEstatements you are planning. - Paste them into the box. Every table becomes a box listing its columns and types; every foreign key becomes a line.
- Drag tables so parents sit near their children. Positions are remembered in this browser. Use Auto-arrange to start over.
- Export an SVG for a design doc, a PNG for a slide, or Mermaid code to paste into a GitHub README.
Reading the diagram
Each line joins a foreign key column to the key it references. The end with the three-pronged “crow’s foot” is the many side, the single bar is exactly one, and a small circle means the relationship is optional. So a line from comments to users with a circle at the users end says a comment may have no user (the user_id column is nullable), and a user can write many comments. The full symbol set is on the crow’s foot notation page.
Designing a good schema
A diagram makes design problems visible: tables with no relationships, columns that repeat the same data in several places, or a many-to-many relationship without a junction table. If you spot repeated groups of columns, walk through database normalization; if you are unsure which column should reference which, the primary vs foreign key explainer lets you try it out.
ER diagram examples
Worked schemas with every relationship explained. Open one to see the diagram and the reasoning, or tap it in “Start from” above to edit it here.
- Hospital Management SystemPatients are admitted to wards, seen by doctors who belong to departments, book appointments, receive prescriptions and are billed.
- Library Management SystemA library catalogues books (titles) and the physical copies on its shelves, lends copies to members, takes reservations and charges fines.
- Banking SystemCustomers hold accounts at branches (some accounts are joint), money moves through transactions, and customers take out loans.
- College Management SystemDepartments run courses, courses are offered as sections each term and taught by faculty, students enrol in sections and receive grades.
- Hotel Management SystemGuests book reservations for one or more rooms, rooms have a type that sets the nightly rate, stays generate charges and payments.
- Student Management SystemA school records students, their guardians, classes and subjects, daily attendance and exam marks.
- Online Shopping SystemAn e-commerce store: customers with saved addresses, products in categories, carts, orders with line items, payments and shipments.
- Employee Management SystemAn HR database: employees in departments, a manager hierarchy, job titles with salary history, projects staffed by several people, and leave requests.
Questions
How can I generate an ER diagram?
Three ways on this page: paste CREATE TABLE statements from your database, write DBML, or describe your app in a sentence and let the AI draft the schema. Each foreign key becomes a crow’s-foot relationship line, and you can drag tables into place and export SVG or PNG.
Can I use AI to generate an ER diagram?
Yes. Type a description such as “a clinic where patients book appointments with doctors” into “Describe the app”. An AI model drafts tables, keys and relationships as editable DBML, and the diagram is drawn from that. Review it: AI schemas are a starting point.
What is the best free tool for creating an ER diagram?
For a schema you already have in SQL, a code-first tool like this one is fastest: no dragging boxes by hand, no account, and the diagram stays in sync with the SQL. For whiteboard-style conceptual diagrams with free-form shapes, general diagram tools such as draw.io suit better.
What input does the ER diagram generator accept?
CREATE TABLE statements from MySQL, MariaDB, PostgreSQL, SQL Server, SQLite or Oracle (including inline REFERENCES, table-level FOREIGN KEY constraints and ALTER TABLE … ADD FOREIGN KEY), or DBML as used by dbdiagram.io. The format is detected automatically.
How do I get the SQL for an existing database?
Export the schema only. MySQL: mysqldump --no-data dbname. PostgreSQL: pg_dump --schema-only dbname. SQLite: .schema in the sqlite3 shell. SQL Server: Script Database as → CREATE in SSMS. Paste the output here.
How are relationships detected?
From foreign keys. Each foreign key becomes a many-to-one line from the child table to the parent table. If the foreign key column is also unique (or is the whole primary key) it is drawn as one-to-one. Nullable foreign keys get the “zero or one” circle on the parent end.
Is my schema uploaded anywhere?
No. Parsing and drawing happen in your browser, and your input and table positions are saved only in this browser’s local storage. The optional “Generate from description” feature sends only the description you type to an AI model.
Can I share an ER diagram without an account?
Yes. “Copy share link” packs the schema into the link itself (after the # sign, compressed), so whoever opens it sees the same diagram. Nothing is stored on a server, which also means very large schemas make long links.
Where can I find ER diagram examples?
Nine worked examples (hospital, library, banking, college, hotel, school, online shopping, employee management and the blog sample) load with one tap from the “Start from” row, and each has its own page explaining every relationship.
Can I export the diagram?
Yes: SVG (sharp at any size, good for docs), PNG at 2× resolution, and the schema as DBML, Mermaid erDiagram code, or SQL for PostgreSQL, MySQL, SQL Server or SQLite.
What do the symbols on the lines mean?
They are crow’s-foot notation. A three-pronged fork means “many”, a single bar means “one”, and a circle means “zero” (optional). Reading a line from the orders table to the customers table as “each order belongs to exactly one customer; a customer has zero or many orders” is typical.
Related tools
- DBML EditorWrite DBML with a live diagram, convert DBML to SQL and back.
- Mermaid ER DiagramTurn a SQL schema into Mermaid erDiagram code for GitHub, GitLab and Notion.
- Crow’s Foot NotationER diagram symbols and a cardinality builder that reads relationships aloud.
- SQL FormatterBeautify SQL in 12 dialects with keyword case, indent and comma style options.
- Database NormalizationStep one messy table through 1NF, 2NF and 3NF.
- CSV to SQLCREATE TABLE with inferred types plus batched INSERT statements.