ErdDocs

Mermaid ER diagram generator

Generate a Mermaid erDiagram from a schema you already have: a SQL dump, a Prisma file, DBML, or ORM models. You see it drawn while you do. Copy the text into a README and GitHub renders it. No account, no install, nothing uploaded.

Your schema

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. 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. You rarely need to, because the schema exists somewhere already. Any of these is a starting point:

  • A dump: pg_dump --schema-only or mysqldump --no-data, including the ALTER TABLE ... ADD CONSTRAINT style that pg_dump writes.
  • An ORM: a Prisma schema, SQLAlchemy models or Sequelize models, read as the tables they generate.
  • 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.

Sometimes a dump declares no foreign keys at all, because Rails and Django projects often enforce them in application code. ErdDocs then recovers the relations from column naming and labels them (by name) in the output. 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. An attribute holds a type, a name, its key markers and a quoted comment. Defaults, nullability and indexes have nowhere to go, so they are dropped on export, and so are type sizes and comments, to keep the diagram short. Some readers need them: an auditor, a client, a new engineer. The data dictionary keeps every one of them. The PlantUML export keeps sizes and nullability while still being text you can diff.

FAQ

What can I generate the diagram from?

Ten inputs: SQL from PostgreSQL, MySQL and SQL Server, 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. Many other generators 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 column carries a normalized type and the markers PK, FK and UK where they apply. After the entities comes one relation line per foreign key, with crow’s foot cardinality and the key column as its label. Type sizes are dropped, so varchar(200) becomes varchar. Mermaid allows parentheses in a type but not the comma in numeric(10,2), and an export has to render.

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