The SQL Minifier takes a formatted, multi-line query and compresses it into a single compact line by removing comments and collapsing all the extra whitespace. What remains is the exact same statement with none of the indentation, blank lines or explanatory notes that make a query pleasant to read but bulky to embed in code or a configuration file.
It is aimed at developers who need to drop a query into a string literal, a JSON config, a log line or a migration script where newlines are awkward or forbidden. A one-line query travels cleanly through systems that mangle whitespace, and it keeps source files tidy when the SQL itself is not the focus of the code you are writing.
Everything runs locally in your browser using JavaScript, so your query never leaves your device. Because SQL routinely exposes table names, column names and business rules, keeping the minification on your own machine avoids sending that internal structure to any remote server for processing.
Features
- Collapses every run of spaces, tabs and newlines into a single space for a compact one-line query.
- Removes single-line comments starting with two dashes and multi-line block comments entirely.
- Preserves string literals and quoted identifiers exactly, so the text inside quotes is never altered.
- Tightens spacing around parentheses, commas and semicolons without breaking the statement.
- Reports the original and minified character counts plus the percentage of size you saved.
- Works on a single statement or a script, keeping semicolons that separate multiple queries.
- Copies the minified query or downloads it as a text file ready to paste into code or config.
How to use SQL Minifier
- Paste your formatted SQL query or script into the input box.
- The tool instantly removes comments and collapses the whitespace into one line.
- Check the statistics to see how many characters you removed and the percentage saved.
- Confirm that any string literals inside the query still contain the exact text you expect.
- Copy the compact query or download it as a file to embed in your code, config or migration.
Benefits
- Developers embed queries in string literals and config files without awkward line breaks.
- One-line SQL survives systems and formats that strip or reformat whitespace and newlines.
- Source files stay tidy when the SQL is incidental rather than the point of the code.
- Removing comments strips internal notes before a query ships to a shared or public config.
- The size statistics show exactly how much smaller the query became after minification.
- Because everything is local, sensitive schema details in the query never leave your device.
Minifying SQL is mostly about transport rather than performance: the database parses whitespace away regardless, so a minified query does not run faster. The benefit is practical, letting you paste a query into a place where a multi-line block would be inconvenient, such as a single-line environment variable, a compact log message or a string inside application code.
The tool protects the contents of quotes before it does anything else, so a value like a single-quoted string that happens to contain the characters of a comment is never treated as a comment. Only genuine SQL comments outside of quotes are removed, which keeps the meaning of the statement identical to the original even after every note has been stripped.
This is a text transform rather than a SQL parser, so it will minify a query even if that query has a syntax error, and it does not attempt to understand dialect-specific constructs. For everyday statements the result is a faithful, compact single-line version; always run the minified query once to confirm it executes exactly as the formatted original did.