TOOLTIKI Lovable tool, really free
Developer Formatting

SQL minifier

What to do

Processed in your browser · nothing is uploaded

Local · quoting tracked, literals untouched
Advertisement
320 × 100

Collapses a SQL statement onto one line and strips comments, without touching what is inside a string literal — which is where every naive whitespace-squasher goes wrong.

How to use the sql minifier

1 Paste your input. The result appears immediately.
2 Pick the operation you want.
3 Copy the result, or save it as a file.

The whole difficulty is string literals. A regex that replaces runs of whitespace with a single space will happily rewrite `WHERE note = 'a b'` into `'a b'`, silently changing what the query matches. The minifier here tracks quoting, so text inside a literal survives exactly, doubled apostrophes included. Comments are removed on the same terms: `--` to end of line and `/* … */`, but only where they are not inside a string. A URL in a literal contains `--` surprisingly often, and a comment stripper that does not know it is inside a quote will truncate the value. Worth saying plainly: minifying SQL saves almost nothing. Query text is a rounding error next to the work the database does, and a minified query is far harder to debug in a slow-query log. The genuine uses are fitting a statement into a single-line config value, a migration tool that wants one statement per line, or a log line that must not wrap.

Questions

No. Quoting is tracked, so whitespace and comment markers inside a literal survive exactly.

SQL:2016 — string literals
Advertisement
300 × 250
Was this tool any good?
INTERNAL SIGNAL ONLY · WE USE IT TO FIND TOOLS WORTH REBUILDING