Mermaid ER diagram generator
Generate a Mermaid erDiagram from a schema you already have — a SQL dump, a Prisma file, DBML, or ORM models — and see it drawn while you do. Copy the text into a README and GitHub renders it. No account, no install, nothing uploaded.
Paste your own schema, then Export → Mermaid.
The erDiagram it writes
The real export of the schema above, trimmed to two entities and their relations. Note the two separate lines from flights to airports — origin and destination are different relations, and collapsing them into one is the usual bug in a generator that thinks in table pairs:
%% Generated with erddocs.com — paste SQL, get an ER diagram and a data dictionary
erDiagram
airports {
serial id PK
char iata UK
varchar city
char country
}
flights {
bigserial id PK
int airline_id FK
varchar number
int origin_id FK
int destination_id FK
timestamptz departs_at
timestamptz arrives_at
}
flights }o--|| airlines : "airline_id"
flights }o--|| airports : "origin_id"
flights }o--|| airports : "destination_id"Start from what you already have
Writing erDiagram by hand is fine for four tables and miserable for forty — and you rarely need to, because the schema exists somewhere already. Any of these is a starting point:
- A dump —
pg_dump --schema-onlyormysqldump --no-data, including theALTER TABLE ... ADD CONSTRAINTstyle that pg_dump writes. - An ORM — a Prisma schema, SQLAlchemy models or Sequelize models, read as the tables they generate rather than as classes.
- Another diagram language — DBML from dbdiagram, or PlantUML from an architecture repository.
- Mermaid itself — paste a diagram out of a README to redraw it, rearrange it, or convert it into something else.
And when a dump declares no foreign keys at all — Rails and Django projects often enforce them in application code — ErdDocs recovers the relations from column naming and labels them (by name) in the output, so you get a connected diagram instead of a page of unlinked tables, and every inferred line says that it was inferred.
Where Mermaid stops
Mermaid is a diagram language, not a schema language: its entity syntax has room for a type and a key marker per attribute and nothing else. Sizes, defaults, nullability, comments and indexes have nowhere to go, so they are dropped on export. If the reader needs those — an auditor, a client, a new engineer — the data dictionary keeps every one of them, and the PlantUML export keeps sizes and nullability while still being text you can diff.
FAQ
What can I generate the diagram from?
Ten inputs: PostgreSQL and MySQL dumps, Prisma schemas, DBML, PlantUML, Django models, SQLAlchemy models, Sequelize models, TypeORM entities, Laravel migrations, and Mermaid itself. The format is detected from what you paste. That is the difference from most generators in this space, which either take SQL only, or take a text prompt and ask a language model to invent a schema.
What exactly does the generated erDiagram contain?
One entity per table with its columns, each carrying a normalized type and the markers PK, FK and UK where they apply, followed by one relation line per foreign key with crow’s foot cardinality and the key column as its label. Type sizes are dropped — varchar(200) becomes varchar — because Mermaid’s attribute grammar has no place for parentheses, and an export that does not render is worse than one that simplifies.
Will it render on GitHub?
Yes. GitHub renders mermaid code blocks natively, and so do GitLab, Obsidian and most static site generators. Identifiers are sanitized on the way out, so a column named with a space or a dot does not produce a diagram that fails to parse in someone else’s README.
Can I edit an existing Mermaid diagram?
Paste it in — Mermaid is an input as well as an output. The diagram is drawn from it, and you can export it as DBML or PlantUML, print it as a data dictionary, or paste the same erDiagram back out. Round-tripping is tested: what the exporter writes, the parser reads back into the same schema.
Is it free?
Generating and copying Mermaid is free at any schema size, with no account — the 25-table limit is on what gets drawn, not on what gets converted. The text carries one comment line naming ErdDocs; a $9 license removes it and lifts the limit.
Related
- DBML to Mermaid — when the starting point is a dbdiagram file.
- SQL to PlantUML — the other text diagram, with sizes and nullability kept.
- Prisma schema to ER diagram — the database a schema.prisma generates.
- SQLAlchemy models to ER diagram — Python models without a Graphviz install.
- Data dictionary generator — everything Mermaid has to drop, kept.
- SQL to ER diagram — the tool itself.