Skip to content
100% local

SQL schema diff

Compare two CREATE TABLE schemas and generate the ALTER TABLE migration between them.

Input
Target schema (CREATE TABLE)
Output

SQL schema diff

Paste your current schema on the left and the schema you want to reach on the right, and this tool writes the migration between them. It compares CREATE TABLE statements table by table and column by column, then generates the CREATE TABLE, DROP TABLE, ADD COLUMN, DROP COLUMN and ALTER COLUMN statements needed to turn the first schema into the second — useful for reviewing a schema change, writing a migration file by hand, or checking what a schema-generation tool actually did.

Pick a database from the Database option — PostgreSQL, MySQL or SQLite — since each writes column changes differently: PostgreSQL uses ALTER COLUMN ... TYPE and SET/DROP NOT NULL, MySQL combines type and nullability into one MODIFY COLUMN statement, and SQLite has no ALTER COLUMN at all, so those cases are noted as needing a table rebuild. Include index changes to also diff CREATE INDEX statements, wrap the output in a transaction, and turn on the rollback option for a second, reverse migration appended below the first.

Dropping a table or column, narrowing a type, or adding NOT NULL can throw away data or fail against rows that don't fit the new constraint. With "Warn about data loss" on, every such step is marked in the output so it's easy to spot before running anything against a real database. Tables that reference each other through a foreign key are created and dropped in dependency order, so the script doesn't fail on a table it needed first.

Everything runs locally in your browser — your schemas are never uploaded anywhere, so it's safe to paste real table definitions from a private database. Copy the migration, download it as a .txt file, or send the output back into the input to keep refining it.

FAQ

Which SQL dialects are supported?
PostgreSQL, MySQL and SQLite. Pick one from the Database option — each writes ALTER COLUMN, index and quoting syntax differently.
Can it detect changes that might lose data?
Yes. Dropped tables, dropped columns, columns narrowed to a smaller type, and columns made NOT NULL are all flagged with a warning comment when "Warn about data loss" is on.
Does it handle foreign key dependencies?
Yes. When one table references another, CREATE TABLE statements are ordered so the referenced table comes first, and DROP TABLE statements are ordered so referencing tables are dropped before the tables they depend on.
What SQL syntax does it read?
Standard CREATE TABLE statements with typed columns, NOT NULL, PRIMARY KEY and REFERENCES, plus standalone CREATE INDEX statements. Statements it does not recognize (inserts, other DDL) are skipped rather than rejected.
Are my schemas uploaded anywhere?
No. Comparing schemas and generating the migration runs entirely in your browser — nothing you paste here is sent to a server.