← All tools
Free tool

SQL schema diff tool

Paste two versions of a PostgreSQL schema and get the structural diff plus the ALTER statements to migrate, added tables, dropped columns, type changes, and key changes, each flagged.

old.sql (current production schema) · 11 lines
new.sql (proposed schema) · 18 lines
migration.sql · 3 changes
+ table comments (3 columns)~ users: +1 col (created_at), -1 col (name), ~1 col~ posts: +1 col (published)
-- New table: comments
-- Generated by dbdiagramr (https://www.dbdiagramr.space)
-- PostgreSQL DDL exported from the interactive ER diagram below.

CREATE TABLE comments (
  id uuid PRIMARY KEY,
  post_id uuid,
  body text NOT NULL
);

ALTER TABLE comments ADD CONSTRAINT fk_comments_post_id FOREIGN KEY (post_id) REFERENCES posts (id);
-- Changes to users
ALTER TABLE users ADD COLUMN created_at timestamptz NOT NULL DEFAULT now();
ALTER TABLE users DROP COLUMN name;
ALTER TABLE users ALTER COLUMN email TYPE varchar(320) USING email::varchar(320);
-- Changes to posts
ALTER TABLE posts ADD COLUMN published boolean DEFAULT false;

Review before running on production. Test on a copy first.

Frequently asked questions

How do I compare two PostgreSQL schemas?

Paste the old schema (e.g. production, from pg_dump --schema-only) on the left and the new schema on the right. The tool lists every added, removed, and changed table and column, then generates the ALTER TABLE statements to migrate, including USING clauses for type changes and warnings where backfills are needed.

Is it free?

Yes, completely free with no signup. Comparison runs in your browser; paste any size schema pair and copy the migration.

Is my schema uploaded anywhere?

No. Parsing, diffing, and ALTER generation run entirely in your browser. Your schemas are never uploaded, stored, or logged.

Which changes are detected?

Added and dropped tables; added, dropped, and altered columns (type, nullability, defaults); primary-key changes; and added foreign keys. Removed foreign keys are flagged with instructions since their constraint names only exist in the live database.

Can I visualize the new schema?

Yes. Click Visualize the new schema to open it in dbdiagramr as an interactive ER diagram, the fastest review step before running the migration.

Related tools

Turn it into an ER diagram

Paste your PostgreSQL connection string and get an interactive ER diagram of your own schema in under 10 seconds. No signup required.