SQL Minifier
Compress SQL into one compact line.
How to use
- 1 Paste your SQL query or batch into the input box.
- 2 Optionally tick "Keep comments" to retain inline notes.
- 3 Read the minified single-line result on the right.
- 4 Copy it for your code, config or logs.
About SQL Minifier
The SQL Minifier squeezes a formatted query — or a whole batch of statements — down to the smallest equivalent single line.
Pretty-printed SQL with its generous indentation and inline comments is wonderful to read, but bulky to embed in a string literal, a config file, a log line or a URL.
This tool removes the cosmetic whitespace, deletes line ("--") and block ("/* ... */") comments, and tightens the spacing around commas, parentheses and semicolons so the result is as terse as possible.
It works by walking the query character by character rather than with a blunt regular expression, so anything that looks like whitespace or a comment marker but actually lives inside a string literal or a quoted identifier is preserved byte-for-byte.
Doubled-quote escapes (such as 'it''s') are handled correctly, and you can choose to keep comments if you only want the whitespace collapsed.
A small counter shows how many characters you saved.
Everything runs locally in your browser — your SQL is never uploaded, logged or stored — so it is safe to paste production queries, and it keeps working offline once the page has loaded.
FAQ
Will minifying change what my query does?
No. Only insignificant whitespace and comments are removed; the contents of string literals and quoted identifiers are preserved exactly, so the query is semantically identical.
Does it understand string literals with -- or spaces inside?
Yes. The minifier tracks string and identifier quoting, so comment markers and whitespace inside literals are never touched.