About sql2erd

Last updated 13 September 2026

sql2erd turns SQL DDL into a clear, interactive entity relationship diagram. Paste CREATE TABLE statements, get a diagram with primary keys, foreign keys and orthogonal connectors — rearrange tables directly on canvas, or export as SVG, PNG, and a Markdown data dictionary.

Everything runs in your browser. There is no upload step, because there is nowhere to upload to.

How it works

Three stages, all client-side:

Once rendered, the diagram behaves as an interactive workbench: you can drag tables to rearrange them while orthogonal connectors re-route in real time, delete tables from the view to isolate sub-graphs without altering your SQL, or enter Focus Mode to hide the editor and view the diagram across the entire viewport. The status line under the editor reports how long each stage took.

Why static parsing

sql2erd never connects to a database. It reads the DDL text only. That is a deliberate trade-off: it means the tool works on a schema that has not been deployed yet, on a migration file in a pull request, or on a production dump you are not allowed to connect to — and it means your credentials are never involved. The cost is that anything not expressed in the DDL (data, statistics, runtime constraints) is invisible to it.

Dialects and structure

PostgreSQL and MySQL DDL are supported, including table constraints, inline and separate FOREIGN KEY declarations, and ALTER TABLE … ADD CONSTRAINT. Partition sub-tables can be shown or hidden. For large schemas, you can designate a hub table as Center and configure concentric rings with direct table pickers, using radial layouts (twopi) to keep complex relationship webs readable.

Exports

Diagrams can be copied as raw SVG code or downloaded as SVG and PNG files. In addition, you can export a structured Markdown Data Dictionary listing all tables, columns, data types, constraints, and comments — formatted and ready to paste into pull requests, engineering wikis, or Confluence.

There is also a SQL minifier

/minify/ removes every comment and all redundant whitespace from MySQL, PostgreSQL and Amazon Redshift SQL — inside PL/pgSQL function bodies too — without changing what it does: strings and quoted identifiers are kept byte for byte, MySQL /*! … */ executable comments are safely preserved, and the three dialects' comment and escaping rules are applied separately. It is plain TypeScript with no WebAssembly to download, so the page is usable the moment it loads — and, like the diagram tool, it never sends your SQL anywhere.

And a SQL formatter

/format/ is the other direction: it indents and wraps a query so it can be read, keeping every comment. What makes it different from the usual online formatter is that it checks its own work — the formatted text is re-lexed with the same dialect rules the minifier uses, and its stream of executable tokens is compared with the input's. If a single token moved, was lost or was merged, you get the position of the difference instead of the output. Three cases are refused outright rather than shown half-broken: MySQL DELIMITER scripts, Redshift backslash escapes, and a reflow that would merge two string constants onto one line. Also entirely client-side.

There is also a command-line version

The same product exists as a local CLI that writes SVG and PNG files, useful for CI pipelines and for schemas you would rather not open in a browser at all. The two share a name and a design, but are separate implementations.

Privacy and terms

Nothing is collected — see the Privacy Policy, which explains how a Content-Security-Policy header enforces that rather than merely promising it. Usage is governed by the Terms of Use; note in particular that generated diagrams should be reviewed before you rely on them.

Support and donation

sql2erd is free, ad-free, and privacy-respecting software built and maintained as an independent project. If the tool saves you time or helps your team, consider supporting its hosting and domain costs on the Donate page.

Contact

contact@sql2erd.dev

© 2026 Ho Hai Nghia. All rights reserved. · sql2erd.dev