Skip to content

Cookie settings

Optional analytics help us understand which pages and tools are useful. If you allow them, we use Google Analytics. Your files are never included, and every tool works the same if you decline. Cookie policy

SQL Minifier Online

Strip comments and newlines to put a query on a single line, for a config value, a shell argument or a log entry that cannot span lines.

Browser tool

SQL

Paste a query or upload a .sql file.

Settings

Block comments often carry optimizer hints.

About SQL Minifier

Collapsing a query onto one line by stripping comments and newlines, for the places that cannot take a multi-line string: a configuration value, a command-line argument, a log entry, a cell in a spreadsheet. Free, with no registration. The query is collapsed in your browser rather than uploaded anywhere.

How to use SQL Minifier

  1. Paste the queryFormatted, commented, however it currently looks.
  2. Take the single lineWhitespace collapsed and comments removed, with string literals left exactly as they were.
  3. Keep the readable versionMinified SQL is for machines. The copy humans maintain should stay formatted.

What is safe to collapse and what is not

Whitespace between tokens carries no meaning in SQL, so collapsing it cannot change a result. Whitespace inside a string literal does, and so does a line break inside a single-line comment — remove the newline and everything after the comment marker is swallowed by it. A parser therefore does this work rather than a search and replace, because anything unable to tell a keyword from the same letters inside quotation marks will hand back a query that runs and answers the wrong question.

What it does not do

  • Comments are discarded, and a comment explaining why a query is written a particular way is often the most valuable line in it. Minify a copy, not the source.
  • Minifying does not make a query faster. The database parses it either way, and the saving is in transport bytes, which is negligible.

SQL Minifier: questions people ask

Does minifying improve performance?
No. The query planner works on the parsed statement, and whitespace is discarded long before anything is executed. The reason to minify is fitting a query somewhere that will not take line breaks.
Is it safe to strip comments?
From a copy, yes. From your source, only if the comments genuinely say nothing — and in SQL they usually explain an index hint or a non-obvious join, which is exactly the knowledge nobody wants to reconstruct later.
Does the SQL minifier work with Oracle, MySQL and PostgreSQL queries?
Yes for ordinary queries, because it works on tokens rather than on one dialect's grammar. Quoted strings, backtick and [bracketed] identifiers and PostgreSQL $$ blocks are kept intact, and a checkbox treats # as a MySQL comment. Oracle's q'[...]' alternative quoting is not recognised, so check any statement that uses it.

Questions about ToolsVerse itself — privacy, cost, what happens to your files — are answered in the frequently asked questions.

The tools people most often need alongside SQL Minifier.

Can’t find the tool you need?

Tell us what you’re looking for and we’ll consider adding it.

Request a tool →