About the SQL Minifier
The SQL Minifier squeezes a neatly formatted query into a single line, removing -- and /* */ comments along the way. Quoted strings and identifiers are kept exactly as written, so values like 'New York' don't change.
How it works
When Minify is selected, the input is trimmed and every run of whitespace, including newlines and tabs, is replaced with a single space. That alone puts the whole query on one line.
Next, any spaces directly before or after a comma, an opening parenthesis, or a closing parenthesis are removed, so "IN (1, 2, 3)" becomes "IN(1,2,3)". Keyword case is not changed in this mode, and nothing else in the query is rewritten.
How to use
- 1
Paste your SQL query into the input box, or click Open file.
- 2
Check the single-line result and the size cards.
- 3
Click Copy or Download to use it.
Worked examples
Compressing a formatted SELECT
A readable query needs to go into a single-line config value.
Minifying an INSERT
Shortening an insert statement for a log line.
Spaces around parentheses are removed, and the lowercase keywords are kept as typed.
Frequently asked questions
Does minifying a SQL query change its behavior?+
Not for typical queries, since databases ignore whitespace between tokens. Queries with -- comments or meaningful spaces inside string literals can change, so check those cases.
Why would I want to minify a query?+
To embed it in application code, a JSON or YAML value, a shell command, or a log line where a single line is easier to handle.
Does it make queries run faster?+
No. The database spends no meaningful time on whitespace. Minifying only changes how the text is stored and displayed.
Is "IN(1,2,3)" without spaces still valid SQL?+
Yes. Spaces around parentheses and commas are optional in SQL, so the minified form runs the same as the spaced version.
Can I get the readable version back?+
Yes. Click Format and the same input is shown with each clause on its own line.