💙 Supporting healthcare non-profits: Metadataloop is free for 6–12 months. Contact Us to get started.
Developer Utility

Mermaid / DBML Converter

Paste CREATE TABLE statements — get Mermaid erDiagram or DBML markup for dbdiagram.io, Notion, GitHub.

Input · CREATE TABLE SQL
Output · Mermaid
Output will appear here.

Convert SQL CREATE TABLE to Mermaid erDiagram or DBML

Paste your SQL schema and instantly get a Mermaid erDiagram block — ready to embed in GitHub Markdown, Notion, or your README — or DBML markup that drops directly into dbdiagram.io. Foreign keys, primary keys, and column types are detected automatically.

Why convert SQL to Mermaid?

  • GitHub renders Mermaid natively — diagrams update with the code, no PNG to maintain.
  • Notion and many wiki engines support Mermaid blocks too.
  • Diagrams stay versioned — diff Mermaid in PRs the same way you diff SQL.

Why DBML?

  • dbdiagram.io renders DBML into shareable interactive diagrams.
  • Cleaner syntax for documentation than full SQL DDL.
  • Round-trips with many ORM/migration tools.

Example

Input SQL:

CREATE TABLE users (
  id INT PRIMARY KEY,
  email VARCHAR(255) NOT NULL UNIQUE
);
CREATE TABLE orders (
  id INT PRIMARY KEY,
  user_id INT REFERENCES users(id),
  amount DECIMAL(10,2)
);

Mermaid output:

erDiagram
    users {
        INT id PK
        VARCHAR email
    }
    orders {
        INT id PK
        INT user_id FK
        DECIMAL amount
    }
    users ||--o{ orders : "user_id"

Common use cases

README ER diagrams

Embed a Mermaid block under your repo's "Schema" section so the diagram updates with the SQL.

Architecture decision records

Pair design docs with diagrams that don't drift from the implementation.

Notion / Confluence pages

Paste the Mermaid block into a code block — most knowledge bases render it.

dbdiagram.io exports

Use DBML output to round-trip into dbdiagram.io for shareable interactive diagrams.

FAQ

Does it understand foreign keys? Yes — both inline REFERENCES clauses and standalone FOREIGN KEY constraints. Each FK becomes a relationship line in the diagram.

Which SQL dialects can I paste? Any dialect whose CREATE TABLE grammar uses parentheses and ends with a semicolon — Postgres, MySQL, Snowflake, SQL Server, SQLite. Backticks, brackets, and double-quotes are all stripped.

Where do I render the Mermaid output? Any Markdown renderer that supports Mermaid (GitHub, GitLab, Notion, Obsidian) or paste it into mermaid.live for a live preview.

Is anything saved? No — your SQL is parsed in-memory and discarded. No accounts, no logs, no AI calls.

⚠ Confirm Delete