SQL to ER Diagram
Home › SQL to Mermaid

SQL to Mermaid

Paste your SQL CREATE TABLE statements and get a Mermaid erDiagram you can copy straight into Markdown, GitHub, or your docs — plus a live, interactive diagram.

Open the diagram tool →
No signup · nothing uploaded · export PNG / SVG / Mermaid / DBML · shareable link
ER diagram of the SQL to Mermaid example schema: users and posts (2 tables, 1 relationship)
The SQL 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 SQL CREATE TABLE statements into a Mermaid erDiagram.
Input
SQL CREATE TABLE statements for PostgreSQL, MySQL, MariaDB, SQLite, SQL Server, Oracle or Snowflake.
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 SQL schema into the editor (PostgreSQL, MySQL, SQLite or SQL Server).
  2. The diagram renders instantly so you can check it.
  3. Click Export → Mermaid and copy the erDiagram code.
  4. Drop it into any Mermaid-aware Markdown (GitHub, GitLab, Notion, Obsidian…).

Example

This SQL:

CREATE TABLE users (
  id SERIAL PRIMARY KEY,
  email TEXT UNIQUE
);
CREATE TABLE posts (
  id SERIAL PRIMARY KEY,
  user_id INT REFERENCES users(id)
);

…exports as this Mermaid:

erDiagram
    users {
        serial id PK
        text email
    }
    posts {
        serial id PK
        int user_id FK
    }
    users ||--o{ posts : "user_id"

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

Guide

The export maps your SQL one-to-one onto Mermaid's erDiagram grammar: each CREATE TABLE becomes an entity block, columns keep their types, PRIMARY KEY / FOREIGN KEY / UNIQUE become PK / FK / UK markers, and each foreign key becomes a relationship line with the right cardinality — ||--o{ for a plain one-to-many, ||--|| for a unique foreign key.

Where the output works: GitHub and GitLab Markdown (fenced as a mermaid code block), Notion code blocks, Obsidian, GitBook, MkDocs with mkdocs-material, and the Mermaid Live Editor. If your target renderer chokes on something, the usual culprit is an exotic column type — rename it to a simple word (string, int) in the export and it will render anywhere.

Why convert via a diagram tool instead of by hand: the live preview catches mistakes before you paste. If the edge between orders and customers looks wrong on the canvas, the Mermaid will be wrong too — fix the SQL, re-export. The canvas is the proof, the export is the artifact.

Why use it

SQL → MermaidSQL → DBMLSQL → PlantUMLPNG / SVG

FAQ

How do I convert SQL to a Mermaid ER diagram?

Paste your CREATE TABLE statements, then click Export → Mermaid and copy the erDiagram code. Foreign keys become 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