SQL Minifier

SQL Minifier

Updated August 21, 2026

SQL minifier online. Compress SQL by stripping comments and extra whitespace while keeping string literals intact. Free SQL compressor in your browser.

Input SQL

0 lines · 0 chars

Loading editor...

Minified SQL

0 lines · 0 chars read-only

Loading editor...

Features

  • Collapse whitespace outside string literals and quoted identifiers
  • Optionally strip -- and /* */ comments
  • Keep quotes, dollar quotes, backticks, and brackets intact
  • Show before and after byte counts
  • Refuse to minify when quotes or parentheses are unbalanced
  • Runs locally so production queries with credentials stay on this device

Common Use Cases

  • Fit a query into a single log line
  • Shrink SQL embedded in JSON or a QR payload
  • Normalize a query before a byte-level hash
  • Strip comments from a sample you are about to share
  • Compare compact vs pretty size

When minifying SQL is safe

Minifying SQL deletes comments and extra spaces. Engines ignore insignificant whitespace, so SELECT a FROM t and SELECT a FROM t with newlines are the same. Spaces inside 'string literals' and quoted identifiers must stay. This minifier tokenizes those regions first.

MySQL -- comments historically needed a space after the dashes. We treat -- as a line comment in every dialect, which matches how people write them today.

Examples

Valid - Pretty input
SELECT
  id
FROM users; -- active only
Valid - Already compact
SELECT id FROM users;
Invalid - Broken, will not minify
SELECT * FROM users WHERE name = 'Ada

Frequently Asked Questions

Will minifying break my string literals?

No. Quoted strings, dollar quotes, backticks, and bracket identifiers are copied through unchanged. Only unquoted whitespace is collapsed.

Are comments always removed?

By default yes. Uncheck “strip comments” if you need to keep -- and block comments.

Is this the same as the formatter with no indent?

No. The formatter parses a dialect grammar. The minifier is a tokenizer. Use the formatter when you want readable SQL; use the minifier when you want fewer bytes.

Tips

  • Keep a copy of the original if a migration tool compares exact SQL text.
  • Strip comments before you paste a query into a public ticket.