SQL Minifier
Shrink your SQL by removing comments, whitespace and line breaks — with live size stats, copy and download, 100% in your browser.
Input
Output
What is SQL minification?
SQL minification is the process of removing unnecessary characters from a SQL query without changing how the database executes it. The minifier strips comments, whitespace, line breaks and redundant spacing around operators and punctuation, producing a functionally identical query that is significantly smaller.
Because database engines parse SQL exactly the same way before and after minification, the query results are unchanged — only the query string size and parse time improve. This makes minification a safe optimisation for embedded SQL or stored queries.
Why minify SQL?
Minifying SQL delivers benefits when SQL is embedded in application code, sent over the network, or stored in configuration files. Smaller query strings reduce transfer size, parse faster, and take up less storage. This is particularly useful for applications that generate or store many SQL queries dynamically.
For applications with hundreds of embedded queries, the combined savings can reduce code size and improve load times. Minified SQL also compresses better with gzip and Brotli, amplifying the savings at the transfer layer.
When to minify SQL
SQL minification is useful in several scenarios:
- Embedded SQL. Minify SQL embedded in application code or configuration files to reduce file size.
- API payloads. Minify SQL sent in API requests to reduce transfer size.
- Stored queries. Minify SQL stored in databases or configuration to save space.
- Logging. Minify SQL in log entries to reduce log file size.
Always keep the original, readable SQL for development and debugging — the minified version is for production use.
How to minify SQL
Minifying SQL with this tool takes a second and happens entirely in your browser. Follow these steps:
- Paste your SQL. Enter the SQL query you want to minify in the input box.
- Click "Minify SQL". The minifier removes comments, whitespace and line breaks, and collapses spacing around operators.
- Copy or download. Click "Copy" to copy the result, or "Download" to save it as a .sql file.
The minified SQL is functionally identical to the original — only the formatting changes.
SQL optimization tips
This minifier removes single-line comments (-- ...), multi-line comments (/* ... */), collapses all whitespace to single spaces, and removes unnecessary spacing around operators and punctuation. It does not change the SQL syntax or logic — the database executes the minified query exactly the same way.
For best results, combine minification with proper query optimisation: use indexes, avoid SELECT *, limit result sets with LIMIT, and use EXPLAIN to analyse query plans. Minification reduces file size, but query optimisation improves execution speed.
Is this SQL minifier free?
Yes, completely free with no sign-up, no limits beyond your device's memory, and no upload.
Will minification break my SQL?
No. The tool only removes comments, whitespace and line breaks. The database executes the minified query identically to the original.
Does it remove comments?
Yes. Both single-line comments (-- ...) and multi-line comments (/* ... */) are removed during minification.
Is my data uploaded?
No. All processing is local. Your SQL never leaves your browser.