Compare SQL - SQL Query Diff
Paste two SQL queries side by side and see which words were added or removed.
How to Compare SQL Queries - Step by Step Guide
Compare SQL Queries Side-by-Side
Paste your SQL queries into both editors to see differences highlighted. Perfect for comparing MySQL, PostgreSQL, SQL Server, or SQLite queries. Additions are highlighted in green, deletions in red. Spacing and line breaks outside quotes are ignored, so a re-indented query does not light up, but text inside quotes is compared character by character. Handy for code reviews and checking what a migration actually changes. Use with SQL Formatter and SQL Validator.
Key Features:
- • Highlights update a moment after you stop typing, with SQL syntax colouring in both editors
- • Word-level change detection; values like 14.50 and 14.5 are never treated as the same
- • Statistics showing additions, deletions, and total changes
- • Swap queries with one click
- • Useful next to version control when you need to see exactly what changed between two versions of a query
Frequently Asked Questions
How does SQL comparison work?
Both queries are split into words, numbers and symbols, and the two lists are compared. Anything only in the original is highlighted in red on the left, anything only in the modified query is green on the right. The counters above the editors show how many blocks were added and removed.
Does reformatting a query show up as a change?
No. Extra spaces, tabs, indentation and line breaks between words are ignored, so a query that was only re-indented shows "No differences found". Text inside quotes is different: there every character counts, so 'a b' and 'a b' are reported as different. Keyword case does count, so SELECT and select are treated as different words.
Are numbers and string values compared exactly?
Yes. Values are compared as text and never converted, so 8901240544102066246 and 8901240544102066247 differ, '00501' and '501' differ, and 14.50 and 14.5 differ too, even though some databases would treat the last pair as equal.
Can I compare large SQL scripts?
Yes, long migrations and dumps with thousands of lines work. When two large scripts are very different, the page switches to comparing whole lines so the browser stays responsive, and it tells you when that happens. Running both scripts through the SQL Formatter first makes the result easier to read.
Is my SQL uploaded anywhere?
No. The comparison runs in your browser and nothing you paste is sent to our server or kept after you leave. A reload starts with two empty editors.
Related tools: SQL Formatter, Compare Text, SQL to JSON and JSON to SQL.
Related Tools
SQL Formatter
Format and beautify SQL queries with proper indentation and syntax highlighting
SQL Beautifier
Beautify and format SQL code with customizable style options
SQL Fixer
Fix broken SQL queries automatically, repair syntax errors, and validate SQL structure
SQL Minifier
Minify and compress SQL queries by removing whitespace and comments
SQL Validator
Validate SQL syntax and detect errors in your queries
SQL to JSON
Convert SQL query results to JSON format