About the SQL Minifier
A multi-line query does not fit in a log line, a YAML value, a URL parameter or a one-line shell command. This minifier removes comments, collapses runs of whitespace to a single space, and trims spaces around parentheses, commas and operators. Text inside single, double or backtick quotes is copied exactly, so a literal containing several spaces or a comment marker is safe.
The tool is text-based and does not parse the SQL, which means it works for any dialect and for fragments as well as complete statements. That also means it will happily minify a query with a syntax error; format it first if you want the error reported. Comments can be kept if they carry hints your database reads, such as optimizer directives.
Whitespace savings are typically 30 to 50 percent. A known trade-off: SQL Server and some drivers prefer a space or newline after a line comment, which is why comments are removed rather than kept inline by default. Use the SQL Formatter to expand the query again.
How to use
- Paste the query.
- Tick "Keep comments" only if they carry directives your database needs.
- Copy the single-line result.
Common questions
- Does it validate the SQL?
- No. It only removes whitespace and comments. Use the formatter to catch syntax errors.
- Are spaces inside strings preserved?
- Yes. Anything inside quotes is untouched.
- Why is there a space after each semicolon?
- So that multiple statements remain separable on one line. Remove it if your driver objects.