SQL Diff Online

Compare SQL schemas, migrations, or queries and find differences instantly.

ORIGINAL1 lines
MODIFIED1 lines

When a SQL diff is the right tool

SQL changes often hide in a long script: a new column, a wider VARCHAR, a foreign-key clause, or an index that was not there last week. Two dumps can look almost the same in an editor and still disagree in a way that would break a migration. A SQL diff is for that moment. You put the previous script on the left, the new script on the right, and read every added, removed, or replaced line instead of scanning both files by eye.

This page compares the text you paste. It does not parse the SQL, connect to a database, or rewrite formatting for you. If you only need to tidy a single script, use the SQL Formatter. If the file already lives in Git, a browser diff is still useful for a throwaway paste, but git diff is the better tool once the change belongs in a repository.

Use cases

Reviewing a schema or migration script

A migration often mixes several decisions: a new column, a changed default, and a fresh index. Pasting the old and new scripts makes each decision visible as its own marked line, so a review can ask “did we mean to add ON DELETE CASCADE?” instead of rereading a 200-line dump. Load Sample on this page uses a short pair of CREATE TABLE statements if you want to see that kind of change first.

Checking a query that was rewritten by hand

Two versions of a SELECT or an UPDATE are easier to trust when the only green and red lines are the predicates you intended to change. Remember that wrapping a long list of columns onto new lines will also show up, even when the query is equivalent.

Comparing an export that was never committed

A dump from staging, a script from a ticket, or a snippet from a colleague often never becomes a pull request. Pasting both versions here is faster than creating a throwaway Git repo, as long as you remember that the result is a text diff, not a catalog compare.

How the comparison works

When you choose Compare, the two panes are compared line by line, using the same style of alignment you see in a typical unified or split diff. Identical lines stay across from each other. A line that exists only on the left is marked as removed. A line that exists only on the right is marked as added. You can switch between split and unified views, and copy the unified result if you need a record.

There is no pretty-print toggle and no dialect setting. Spaces, tabs, blank lines, comments, and keyword case are all part of the text. That honesty matters: the result is easy to read, and it will not pretend that two scripts are the same when only a parser would consider them equivalent.

Example — a new column in a CREATE TABLE
CREATE TABLE users (
  id       INT PRIMARY KEY,
  username VARCHAR(50) NOT NULL UNIQUE,
  email    VARCHAR(100) NOT NULL UNIQUE
);

CREATE TABLE users (
  id       INT PRIMARY KEY,
  username VARCHAR(50) NOT NULL UNIQUE,
  email    VARCHAR(100) NOT NULL UNIQUE,
  role     ENUM('admin','user') NOT NULL DEFAULT 'user'
);

The existing columns stay unchanged. The new role line appears only on the right. That is the kind of schema edit this page is meant to make obvious.

Example — equivalent SQL that a line diff still marks
select id, email from users;
SELECT id, email FROM users;

These two statements are the same query for most engines, but the keyword case is different, so every line is marked as changed. If that is the only difference you see, format both sides the same way — the SQL Formatter can tidy a single script — and compare again.

What this tool does not do

It does not parse SQL, canonicalize identifiers, ignore case, or sort table definitions so that two dumps of the same catalog line up. It does not connect to a server or run a statement. Nothing is uploaded. Very large dumps can still be pasted, but they may make the tab feel slow. For a general source comparison that is not specifically SQL, use Code Diff.

How to use SQL Diff

  1. Paste the older or expected SQL into the original pane.
  2. Paste the newer SQL into the modified pane.
  3. Choose Compare. Switch between split and unified views, and copy the result if you need to keep a record.
  4. Use Swap if the sides are reversed, Clear when you are finished, or Load Sample to try a short schema example first.

Frequently asked questions

Does SQL Diff parse the SQL or understand a dialect?

No. The two panes are compared as plain text, line by line. The page does not parse statements, expand objects, or distinguish MySQL, PostgreSQL, SQLite, or SQL Server. Invalid SQL can still be pasted, because nothing is validated.

Will two queries that only differ in keyword case look the same?

Usually not. select and SELECT are the same for most engines, but a line diff treats them as different text. The same is true of extra spaces or a keyword wrapped onto the next line. Format both sides the same way first if you only care about the schema or the logic.

Can I compare a full schema dump or a migration file?

Yes. Paste the complete text, including comments and statements you would not run by themselves. Comments are compared as text, so a rewrapped comment will show up even when the SQL itself did not change. Load Sample uses a short CREATE TABLE pair if you want to try that kind of change first.

Does this tool apply or execute the SQL?

No. It never connects to a database and never runs a statement. It only shows how two texts differ. Use your database client or a migration tool when you need to apply a change.

Is my SQL sent to a server?

No. Comparison runs in your browser. Closing the tab discards what you pasted. Do not paste dumps that contain secrets, personal data, or connection strings if you would not be comfortable with them sitting in memory on this device.

Is there a file size limit?

There is no server-imposed limit, because nothing is uploaded. A few thousand lines is comfortable. A multi-megabyte dump can make the page feel slow; in that case, compare a smaller excerpt or use a local tool.

How is this different from Code Diff?

The comparison is the same kind of line diff. This page exists so a schema or query change has its own URL and examples. It does not pretty-print SQL before comparing. If you want keywords uppercased and indentation tidied first, use the SQL Formatter, then paste the results here.

Related tools and guides

References

  • Schema comparison in a database client (for example, comparing two live catalogs) works from objects and constraints, not from lines of a dump. Use that when the same table can be written in more than one order and a text diff would be noisy.
  • Migration tools such as Flyway or a vendor schema-diff utility are the right place to generate and apply a change. This page only shows how two scripts differ as text.
  • If the SQL already lives in Git, a local git diff keeps the change with its history. A browser diff is still useful for a throwaway paste that was never committed.