SQL to ER Diagram
Home › SQL to DBML

SQL to DBML

Paste your SQL CREATE TABLE statements and export them as DBML — ready for dbdiagram.io and other DBML tools — while you preview the live ER diagram.

Open the diagram tool →
No signup · nothing uploaded · export PNG / SVG / Mermaid / DBML · shareable link
ER diagram of the SQL to DBML example schema: customers and invoices (2 tables, 1 relationship)
The SQL to DBML example below, drawn by the tool: customers and invoices (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 DBML.
Input
SQL CREATE TABLE statements for PostgreSQL, MySQL, MariaDB, SQLite, SQL Server, Oracle or Snowflake.
Output
DBML 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, SQL Server, Oracle…).
  2. The diagram renders instantly so you can confirm the tables and relations.
  3. Click Export → DBML and copy the result.
  4. Paste it into dbdiagram.io or any DBML-based workflow.

Example

This SQL:

CREATE TABLE customers (
  id BIGINT PRIMARY KEY,
  name VARCHAR(120) NOT NULL
);
CREATE TABLE invoices (
  id BIGINT PRIMARY KEY,
  customer_id BIGINT NOT NULL REFERENCES customers(id),
  total NUMERIC(10,2)
);

…exports as this DBML:

Table "customers" {
  "id" bigint [pk]
  "name" varchar(120) [not null]
}

Table "invoices" {
  "id" bigint [pk]
  "customer_id" bigint [not null]
  "total" "numeric(10,2)"
}

Ref: "invoices"."customer_id" > "customers"."id"

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

Guide

The conversion is deliberately boring and predictable: CREATE TABLE users becomes Table users, column types are normalised to DBML's style (SERIAL → serial with [pk, increment]), NOT NULL becomes [not null], UNIQUE becomes [unique], and each foreign key — whether inline or in an ALTER TABLE — becomes a Ref: line. Nothing is invented, nothing is dropped silently.

Why people convert SQL to DBML:

The live diagram on this page is the verification step: if the canvas shows the relations you expect, the DBML contains them too — both come from the same parse. Export, copy, done. And since the conversion is client-side, production dumps with real table and column names never leave your machine.

Why use it

SQL → DBMLSQL → MermaidSQL → PlantUMLPNG / SVG

FAQ

How do I convert SQL to DBML?

Paste your CREATE TABLE statements, then click Export → DBML and copy the output. Tables become Table blocks and foreign keys become Ref: lines.

Is this a free dbdiagram importer?

Yes — convert SQL to DBML for free and paste it straight into dbdiagram.io, with no account.

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