Skip to content
Free tool · SQL to Mermaid

SQL to Mermaid ERD and DBML, in your browser.

Paste the CREATE TABLE statements from a schema dump and get an entity relationship diagram you can drop into GitHub, GitLab, Notion or Obsidian, or a DBML file for dbdiagram.io. The conversion runs entirely in this page, so the SQL never leaves your machine.

Mermaid erDiagram

What it reads

Tables, columns, keys and the relationships between them.

The converter understands CREATE TABLE with inline and table-level primary keys, unique constraints and REFERENCES clauses, plus the ALTER TABLE ... ADD CONSTRAINT statements that pg_dump, mysqldump and SQL Server Management Studio put at the end of a script. A required foreign key is drawn as a mandatory relationship, a nullable one as optional, and a foreign key that is also unique as one to one.

Where to get the SQL

PostgreSQL: pg_dump --schema-only. MySQL: mysqldump --no-data. SQL Server: Generate Scripts in Management Studio, schema only.

Where to paste the result

A fenced mermaid block renders on GitHub, GitLab, Notion and Obsidian, and mermaid.live previews it. DBML opens in dbdiagram.io and dbdocs.

What it skips

Views, functions, triggers, indexes that are not unique, and CHECK constraints. A very large schema produces a diagram too dense to read, so paste the tables that belong together.

The diagram that does not go stale

Generated from the live catalog instead of a dump.

A diagram converted from a dump is correct until the next migration. Taavik reads the catalog of PostgreSQL, MySQL, SQL Server and Redshift through an agent inside your network, draws the schema map on every scan, and exports the same diagram as Mermaid, DBML or SQL whenever you need it, together with a data dictionary and a history of every schema change. The free plan covers one database connection.

FAQ

Common questions

Is the SQL uploaded anywhere? +

No. The conversion is plain JavaScript running in this page. Nothing is sent to a server, which you can confirm in the network tab of the browser developer tools.

Which SQL dialects are supported? +

CREATE TABLE and ALTER TABLE statements from PostgreSQL, MySQL and MariaDB, and SQL Server, including quoted, backtick and bracketed identifiers and GO batch separators.

How are relationships drawn in Mermaid? +

Each foreign key becomes a line from the referenced table to the referencing one. A NOT NULL foreign key is mandatory, a nullable one is optional, and a foreign key that is unique or is the whole primary key is one to one.

Why do some types look different in the diagram? +

Mermaid does not allow spaces or commas in attribute types, so character varying becomes character_varying and numeric(12,2) becomes numeric(12-2). The DBML output keeps the original type.

Can it generate the diagram straight from a database? +

This page works from SQL text only. Taavik generates the same Mermaid and DBML exports directly from a live database through an on-premises agent, and keeps them current as the schema changes.

Try it

Stop regenerating the diagram by hand.

Connect one database for free and the schema map, data dictionary and Mermaid export follow every change.