SQL ER Diagram Generator
Paste the CREATE TABLE statements of a database and see its structure as an entity relationship diagram. Tables show their columns with primary and foreign key markers and types, relationship lines use crow’s foot notation for one-to-many and optional links, and the diagram can be downloaded as SVG or PNG. The same model is written as Mermaid erDiagram code that GitHub, GitLab and many documentation tools render.
- Runs in your browser
- No sign-up
- Free to use
Diagram
How to use SQL ER Diagram Generator
- Paste CREATE TABLE statements (from a dump or migration).
- Choose all columns or keys only.
- Look at the diagram and download it as SVG or PNG.
- Copy the Mermaid code into a README or wiki.
SQL ER Diagram Generator features
Automatic layout
Referenced tables on the left, dependent tables to the right.
Keys marked
PK and FK labels, types and nullable columns.
Crow’s foot lines
One-to-many and optional relationships.
Downloads
SVG for documents, PNG for slides and chats.
Mermaid code
erDiagram text for GitHub, GitLab, Notion and mermaid.live.
Any dialect
MySQL, PostgreSQL, SQLite and SQL Server syntax.
When to use SQL ER Diagram Generator
- Documenting a database in a README or wiki.
- Understanding an inherited schema quickly.
- Reviewing a schema change with a team.
- Adding a diagram to a design document or presentation.
SQL ER Diagram Generator FAQ
Where do the relationship lines come from?
From the foreign keys: inline REFERENCES, FOREIGN KEY constraints and ALTER TABLE … ADD FOREIGN KEY statements, as written by mysqldump and pg_dump.
What do the line ends mean?
The crow’s foot is at the “many” side, the bar at the “one” side, and a small circle marks an optional (nullable) reference.
How do I use the Mermaid code?
Paste it into a ```mermaid code block on GitHub or GitLab, into Notion or Obsidian, or into mermaid.live to edit and export it.
Can it draw big schemas?
Yes, but diagrams with dozens of tables get wide. Choose “Keys only” to make them more compact.
Does it connect to my database?
No. It only reads the SQL you paste, in your browser.
How do I get the SQL of an existing database?
Export the schema only, for example with mysqldump --no-data or pg_dump --schema-only, and paste the result.
Seeing a schema
A list of CREATE TABLE statements describes a database completely, but it is hard to see the structure in it: which tables are central, which depend on which, and where the many-to-many links are. An entity relationship diagram shows the same information visually, and it is the first thing many developers ask for when they join a project.
The generator parses the SQL into tables, columns and foreign keys. Columns that form the primary key are marked PK, columns that are part of a foreign key FK, and each column shows its type and a question mark when it is nullable. Keys-only mode leaves out the other columns for large schemas.
Tables are placed in columns by dependency: tables that reference nothing are on the left, and each table is placed to the right of the tables it references. Relationship lines run from the foreign key column to the referenced key, with a crow’s foot at the many side, a bar at the one side and a circle when the reference is optional.
The diagram is an SVG drawn in your browser, which stays sharp at any size; the PNG download is rendered at twice the resolution for slides and chat messages. Colours follow the light or dark theme of the page.
Mermaid is a text format for diagrams that many platforms render directly. The generated erDiagram code lists every table with its typed attributes and key markers, and every relationship with its cardinality, so the diagram can live in version control next to the SQL and be updated by editing text.