Skip to content
BEAD

SQL Diff

Compare two SQL queries or schemas after canonical formatting — ignore whitespace and casing noise.

Diff (canonicalized)+5 4
SELECT
id,
- email
+ email,
+ last_login
FROM
users
WHERE
status = 'active'
- AND created_at > '2024-01-01'
+ AND created_at > '2024-06-01'
ORDER BY
- created_at DESC
+ last_login DESC
LIMIT
- 50;
+ 100;

How it works

Both inputs are formatted to a canonical shape (consistent keyword case, indentation, and clause breaks) and then diffed line by line. That way whitespace and casing differences don't show up as changes — only real edits do.

Use it for

  • Comparing two versions of a query during a refactor
  • Diffing two CREATE TABLE statements side by side
  • Spot-checking generated SQL against a hand-written reference

You might also like