SQL Minifier
SQL minifier online. Compress SQL by stripping comments and extra whitespace while keeping string literals intact. Free SQL compressor in your browser.
Input SQL
Loading editor...
Minified SQL
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
SELECT
id
FROM users; -- active onlySELECT id FROM users;SELECT * FROM users WHERE name = 'AdaFrequently Asked Questions
No. Quoted strings, dollar quotes, backticks, and bracket identifiers are copied through unchanged. Only unquoted whitespace is collapsed.
By default yes. Uncheck “strip comments” if you need to keep -- and block comments.
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.