SQL to ER Diagram
Home › DBML to Mermaid

DBML to Mermaid

Paste DBML and export it as a Mermaid erDiagram you can drop into Markdown, GitHub or your docs — while you preview the live, interactive diagram.

Open the diagram tool →
No signup · nothing uploaded · export PNG / SVG / Mermaid / DBML · shareable link
ER diagram of the DBML to Mermaid example schema: users and posts (2 tables, 1 relationship)
The DBML to Mermaid example below, drawn by the tool: users and posts (2 tables, 1 relationship).

At a glance

What it is
SQL to ER Diagram is a free, open-source browser tool that turns DBML into a Mermaid erDiagram.
Input
DBML (Database Markup Language) text.
Output
Mermaid erDiagram code to copy, alongside a live interactive diagram.
Cost
Free. MIT-licensed open source. No account or signup.
Privacy
Runs entirely in your browser. The schema is never uploaded, and share links carry the diagram in the URL fragment, which is not sent to a server.
Limits
It never connects to your database itself: you paste schema text, or run one read-only catalog query in your own client and paste the result. There are no accounts, so there is no real-time multi-user editing; diagrams are kept in your browser, as a saved file, or as a share link. Layout stays smooth at around 300 tables.

How it works

  1. Paste your DBML (from dbdiagram.io or a .dbml file) — DBML is auto-detected.
  2. The diagram renders instantly so you can confirm tables and relations.
  3. Click Export → Mermaid and copy the erDiagram code.
  4. Drop it into any Mermaid-aware Markdown (GitHub, GitLab, Notion, Obsidian…).

Example

This DBML:

Table users {
  id integer [pk]
  email varchar [unique]
}
Table posts {
  id integer [pk]
  user_id integer [ref: > users.id]
}

…exports as this Mermaid:

erDiagram
    users {
        integer id PK
        varchar email
    }
    posts {
        integer id PK
        integer user_id FK
    }
    users ||--o{ posts : "user_id"

Copy it from Export → Mermaid. Try it with your own →

Guide

This conversion maps DBML's relational model onto Mermaid's erDiagram grammar: each Table becomes an entity block, [pk]/[unique]/[ref: settings become PK/UK/FK attribute markers, and each Ref: line becomes a relationship with matching cardinality — a one-to-many > ref becomes ||--o{, a one-to-one - ref becomes ||--||.

The destination matters: Mermaid renders natively in GitHub, GitLab, Notion, Obsidian and most static-site generators. Converting DBML → Mermaid is how you take a schema that lives in a DBML toolchain (dbdiagram, dbdocs) and put it in a README that must render without JavaScript or images — Mermaid blocks are text, so they diff, review and survive repo moves.

As with every export on this site, the live diagram is the proof: what you see on the canvas before copying is exactly what the Mermaid encodes, because both come from the same parse. If a Ref is missing from the render, it was missing from the DBML — fix it once, export again.

Why use it

DBML → MermaidDBML → PlantUMLDBML → SVG

FAQ

How do I convert DBML to Mermaid?

Paste your DBML, then click Export → Mermaid and copy the erDiagram code. Tables become entities and Ref: relations become Mermaid relationships.

Where can I use the Mermaid output?

Anywhere Mermaid renders: GitHub & GitLab Markdown, Notion, Obsidian, docs sites, and the Mermaid Live Editor.

Is my schema uploaded anywhere?

No. Everything runs locally in your browser — your schema is never uploaded to or stored on any server.

Is it free?

Yes. It is completely free and open source, with no account or sign-up required.

Related