How to use SQL Minifier
- Paste the SQL to compress.
- Pick the dialect and decide whether comments should be kept.
- Copy the single-line result.
SQL Minifier features
- Collapses any SQL to a single line
- Removes -- and /* */ comments, or converts them to inline block comments
- Keeps string literals, quoted identifiers and parameters intact
- Dialect-aware tokenisation (MySQL # comments, SQL Server [brackets], PostgreSQL $$ quotes)
- Shows bytes saved and percentage
SQL Minifier example
Minify a commented query
Input:
-- active users
SELECT id,
name /* display */
FROM users
WHERE active = 1;Output:
SELECT id, name FROM users WHERE active=1;Frequently asked questions about SQL Minifier
Are string literals and comments handled safely?
Yes. The minifier tokenises the SQL, so whitespace inside quoted strings is kept and comments are removed (or converted to /* */ blocks if you choose to keep them).
Why keep comments?
Some teams use comments as query tags for monitoring tools (for example /* app:checkout */). Tick "Keep comments" to preserve them in block form on the single line.
Is the minified SQL still valid?
Yes. A single space is kept wherever two tokens would otherwise merge, so keywords, identifiers and operators stay separate.
What is this useful for?
Embedding SQL in JSON configs, log lines, URL parameters, code strings and anywhere a single line is easier to handle.