DBML to ER diagram
Paste a DBML file (dbdiagram’s schema language) and get an interactive ER diagram straight away. You also get the printable data dictionary that every other DBML viewer leaves out. No account, nothing installed. The file is parsed in your browser and never uploaded.
The example carries notes, so its dictionary has a Description column. Replace it with your own file.
A viewer is half of what you needed
ErdDocs gives you both halves from one paste. There are many places to look at a DBML file. dbdocs makes a document from DBML too, after a login, and publishes it on its own site. Here it takes one paste, and the document stays on your machine. A diagram answers “how do these tables connect”. It does not answer “what is in orders.status, can it be null, what is the default". One click from the diagram above is a data dictionary. It lists every table, column, type, nullability, default, index and both directions of every relation, with your notes as descriptions. You can print it and hand it to an auditor, a client, or the person who joins on Monday.
The diagram is interactive. Drag tables where you want them, hide the ones that are noise, and click a relation to read its cardinality. Then put the arrangement in the URL, so the next person opens the picture you meant.
What the parser takes from DBML
- Columns and their settings:
[pk],[not null],[unique],[default: …],[increment], and the type exactly as you wrote it, size and all. - Composite keys and indexes. An
Indexesblock with(a, b) [pk]makes a real composite primary key, which is how the line items table above is keyed. - Both ways of writing a reference. You can write
ref: > customers.idinline on the column, or a standaloneRef:line at the bottom of the file. Either becomes a solid relation, because DBML declares it. - Notes and enums. Notes become descriptions, and enum blocks become types the dictionary lists with their values.
And the way back
Most DBML files are not written by hand. They are produced from a database someone already has. That direction works here too: paste a pg_dump --schema-only file, a schema.prisma, or a Mermaid diagram, and export DBML. The round trip is tested. What the exporter writes, the parser reads back into the same schema. That is how a stray space in a type got caught before it shipped.
FAQ
Which parts of DBML are read?
Table blocks with column types and settings (pk, not null, unique, default, note). Composite primary keys and indexes declared in an Indexes block. Enum definitions, both inline refs written as ref: > and standalone Ref lines, and Note text on tables and columns. A Project block is read for its database_type and otherwise ignored, because it describes the file rather than the schema.
Is this dbdiagram.io?
No relation. ErdDocs reads DBML, dbdiagram’s schema language. It is clean enough that people write it by hand. ErdDocs needs no account and keeps the file on your machine. It also adds the document half: the same paste that draws the diagram produces a data dictionary you can print.
Can I go the other way and get DBML out?
Yes. Paste a PostgreSQL, MySQL or SQL Server script, a Prisma schema, or Mermaid, and export DBML. That is how most DBML files that are not written by hand get made. The round trip is tested. What the exporter writes, the parser reads back into the same schema.
What do notes turn into?
Descriptions. A Note on a table or a column becomes the Description column of the data dictionary. A DBML file with notes produces a document that needs no further editing. A file without notes gets no Description column.
Is it free?
Drawing the diagram and exporting the picture are free, with no account, for schemas up to 25 tables. Larger files are parsed completely and the extra tables are shown as locked placeholders. One payment of $9 unlocks any size, the complete dictionary and exports without our mark.
Related
- DBML to Mermaid: the same file as
erDiagramsyntax for a README. - Database documentation tools: where a browser generator sits among the open-source and platform options.
- Prisma schema to ER diagram: for schemas that live in
schema.prisma. - SQL to PlantUML: when the target is a UML toolchain.
- Data dictionary generator: the document half, in detail.
- Example schemas: fourteen domains to paste and take apart.
- SQL to ER diagram: the same tool with every format it reads.