SQL Minifier
Shrink a SQL statement by stripping line and block comments and collapsing redundant whitespace and line breaks to single spaces. String literals and quoted identifiers ('...', "...", `...`) are always preserved exactly — nothing inside a quote is ever altered, and an unterminated string or comment is reported as an error rather than silently mishandled. Paste directly or upload a .sql file. Runs entirely client-side — nothing is uploaded.
About this tool
This tool shrinks a SQL statement by removing everything that doesn't change what it does: line comments (--), block comments (/* */), and redundant whitespace and line breaks, which collapse to single spaces. It's not a full SQL parser — it doesn't validate your query's logic — but it does carefully track string literals ('...'), double-quoted identifiers ("..."), and backtick-quoted identifiers (`...`), copying their contents through completely untouched, so a string containing what looks like a comment marker or extra spacing is never altered. An unterminated string or comment is reported as an error rather than silently consuming the rest of the file. It runs entirely client-side — nothing you paste or upload is ever sent anywhere.
What you can do
- Strip comments (-- and /* */) and collapse whitespace to shrink a SQL file
- String and identifier literals ('...', "...", `...`) are always preserved exactly
- Paste directly, or upload a .sql file
- Nothing is uploaded — minification happens locally in your browser
How to use
Step 1
Add your SQL
Paste it directly, or upload a .sql file.
Step 2
Minification runs live
Comments are stripped and whitespace collapsed as you type.
Step 3
Copy the result
Copy the compact SQL, ready to embed in an app or migration file.
Example
This SQL:
Input
SELECT a, b FROM t -- only active rows WHERE x = 1 AND y = 2
Minified
SELECT a, b FROM t WHERE x = 1 AND y = 2
minifies to that — the comment is gone, and every line break becomes a single space.
How your data is handled
This tool is labeled 🟢 Browser: your SQL is minified directly in your browser — nothing is uploaded to a server, and nothing about it is retained once you leave the page.
Frequently asked questions
Does minifying change what my query does?+
No — only comments and non-significant whitespace are removed. Every keyword, literal value, and clause is preserved exactly, just without the extra formatting.
Is text inside a string literal ever touched?+
No — anything inside 'single quotes', "double-quoted identifiers", or `backtick-quoted identifiers` is copied through byte-for-byte, including spacing and anything that looks like a comment marker.
Why did it say my SQL has an unterminated string or comment?+
A quote or a /* block comment was opened but never closed before the input ended — this is reported as an error rather than silently treating the rest of the file as part of that string or comment.
Can I use this together with the SQL Formatter?+
They're opposites by design — format for readability while editing, minify before shipping or embedding in code where size matters more than readability.
Is my SQL uploaded anywhere?+
No — whether pasted or loaded from a file, minification happens directly in your browser. Nothing here ever leaves your device.