Home » Developer Tools » SQL Minifier
Paste SQL and get a compact version in seconds, right in your browser.
Last updated 13 November 2026
Your code never leaves your browser. Everything runs locally on your device.
Long SQL queries with comments and extra spacing are hard to paste into logs, chats, and config fields. The SQL Minifier shrinks your query into one compact line while keeping its logic exactly the same.
Everything runs in your browser, so your queries are never uploaded to a server. Paste your SQL, minify it, and copy the result straight into your project.
SQL minification takes a readable query and removes every character the database does not need. It deletes comments, collapses extra spaces and line breaks, and drops spaces around symbols where the query still reads the same to the database. The result is one compact line that means exactly what the original meant. Use it on the copy you paste somewhere else, and keep your formatted original for editing. If you ever need to read a minified query again, the SQL Beautifier formats it back into neat readable lines.
Here is a small query run through the tool, with the exact numbers from a live test:
Input, 39 characters:
SELECT * FROM users WHERE id = 1;
Output, 29 characters:
SELECT*FROM users WHERE id=1;
The output is 29 characters, down from 39. That is 10 characters removed, and 10 divided by 39 is 0.2564, so the query is about 26 percent smaller. Note the spaces around the star are gone, which looks unusual but is valid SQL, while the space between users and WHERE is kept because the words would run together without it.
The built in sample query shows the same saving on a realistic query. It starts at 246 characters and minifies to 200 characters, which is 46 characters removed, or about 19 percent smaller. The comment like text inside its strings, such as 'active -- not a comment', is left untouched, so the query still means the same thing.
No. Minifying only changes the text of the query, not how the database runs it. The database builds the same execution plan for the minified query as it did for the original, so the query itself takes the same time to run. The saving is in moving and storing the text: a smaller query is quicker to paste into a log, a config file, or an API payload, and it takes less room wherever you store it.
This tool never runs your query, so it cannot speed up a slow query or fix a bad one. If a query is slow, look at indexes and the execution plan for that database instead. Minifying is packaging, not tuning.
Minifying and formatting are opposite operations on the same query. Minifying shrinks a query into one compact line for sharing and storing. Formatting expands it into indented lines with each clause on its own line, so a person can read and edit it. Neither changes what the query does.
Use the SQL Beautifier when you need to read or edit a query, and use this minifier when you need to ship it. A good habit is to minify only after you have finished editing, and to keep the formatted version as the copy you work from.
This tool supports four dialects: SQL standard, MySQL, PostgreSQL, and SQLite. Pick the dialect that matches your database before you minify, so the formatting step understands your syntax. It does not offer SQL Server, Oracle, MariaDB, or BigQuery. If your query uses syntax from one of those, pick the closest of the four and check the result before you use it.
Minified SQL is useful anywhere a query has to fit into a small space or travel as text. Common uses are:
Do not minify the copy you keep in source control. Keep the formatted original there, and minify only the copy you send somewhere else.
Keep the formatted original in source control, test the minified query before you deploy it, and minify only after you have finished editing. Use parameterized queries in your code rather than pasting values into SQL, whether the query is minified or not.
Two limits are worth knowing. First, scripts with more than one statement and stored procedures collapse to a single line, and this tool has no option to keep line breaks, so test those with care before you use them. Second, this tool formats your query first and minifies second, so an unusual but valid query that the formatter cannot parse shows an error even though a plain text minifier would have handled it. If that happens, simplify the query or try a different dialect.
Yes, it is completely free with no sign up.
Yes. Minifying only removes comments and extra whitespace. Your query keeps the same logic and returns the same results.
No. Text inside string literals and quoted identifiers is left untouched, even when it looks like a comment.
By default comments are stripped for the smallest output. Uncheck the strip comments option if you want to keep them.
No. All minifying happens in your browser on your own device, so your queries never leave your computer.
The tool shows a clear error message and keeps your input untouched, so you can fix the error and try again.
No. Minifying only makes the text smaller. The database builds the same execution plan for the minified query as for the original, so the query takes the same time to run. The saving is in moving and storing the query, not in running it.
Yes. Minifying only removes spacing and comments, so all of the query is still there. Paste the minified query into the SQL Beautifier on this site and it formats the query back into neat readable lines you can read and edit.
No. A comment that starts with a hash sign is left in place. This tool only strips comments that start with -- or that sit inside /* */. Keep that in mind for MySQL scripts that use hash comments, since those comments stay in the output.
An optimizer hint such as /*+ */ is stripped like any other block comment when the Strip comments box is ticked. If a hint changes how your query runs and you need to keep it, uncheck the Strip comments box before you minify.
Four: SQL standard, MySQL, PostgreSQL, and SQLite. Pick the dialect that matches your database before you minify. SQL Server, Oracle, MariaDB, and BigQuery are not offered.
This tool formats your query first and minifies second. If the formatter cannot parse an unusual but valid query, the tool shows an error and leaves your input untouched. A plain text minifier would not hit this limit, but this tool formats first. Try simplifying the query or picking a different dialect, then minify again.
If you work with data files too, try the CSV to JSON converter to turn spreadsheet exports into JSON.