A SQL minifier takes a nicely indented, multi-line query and squeezes it down to the smallest valid one-line form. It strips the line breaks, runs of spaces and tabs, and (optionally) the comments that make SQL readable for humans but bloat it when you need to store or transmit the statement as a single string. The result is byte-for-byte equivalent in meaning — it just takes up far less space. This is the mirror image of pretty-printing: where a formatter expands SQL for reading, a minifier compacts it for machines.
How it works
Naively deleting whitespace breaks SQL, because some spaces are load-bearing (GROUP BY must
keep its gap) and some spaces live inside string literals where they must never be touched.
This tool avoids that by tokenising the statement first. It walks the SQL character by
character and classifies each run as whitespace, a line or block comment, a single-quoted
string, a double-quoted or backtick identifier, a number, a keyword or a punctuation token —
correctly handling doubled-quote escapes like '' and "".
Once the input is a clean stream of tokens, minifying is safe: whitespace tokens are dropped, comments are removed or normalised based on your settings, recognised keywords are re-cased, and a single space is re-inserted only where two tokens would otherwise fuse into one (two words, a word next to a number, and so on). Because string and identifier tokens are copied through untouched, the spacing inside your quoted values is always preserved. Finally the tool reports input vs. output byte counts, the percentage saved, and how many statements, comments and string literals it found.
Example
Paste a formatted analytics query like this:
SELECT u.country_code,
COUNT(*) AS users -- per country
FROM users AS u
WHERE u.status = 'active'
GROUP BY u.country_code;
With uppercase keywords and strip comments on, you get a single compact line:
SELECT u.country_code,COUNT(*) AS users FROM users AS u WHERE u.status = 'active' GROUP BY u.country_code;
The stats panel shows roughly a 40-60% byte reduction on typical formatted queries — and the
value 'active' keeps its quotes and content exactly. Everything is computed locally in your
browser; no query is ever uploaded.