SQL Minifier
SQL ToolsCollapse SQL to one line and strip comments and extra whitespace.
Runs entirely in your browser โ nothing is uploaded
What people do next
Features
- Collapses a query onto a single line.
- Strips -- and /* */ comments without touching quoted strings.
- Keeps string literals byte-for-byte, including any spaces inside them.
- Five dialects, so quoted identifiers survive intact.
- Runs in your browser โ nothing is uploaded.
How to use the SQL Minifier
- 1Paste the SQL you want collapsed.
- 2Choose the dialect.
- 3Copy the single-line result.
Frequently asked questions
Is minified SQL faster?
No. The database parses your query before doing anything else, and whitespace is discarded at that point โ a minified query and a formatted one produce an identical execution plan. Minifying is about fitting a query somewhere, not about speed.
Then what is it actually for?
Putting a query into a place that dislikes newlines: a JSON config value, an environment variable, a single spreadsheet cell, a command-line argument, or a log line you want to stay on one row. It is also a quick way to strip comments before sharing a query.
Will it break a query containing a comment marker inside a string?
No, and this is the case that catches naive minifiers. A literal such as 'https://example.com' contains a double slash, and a value like '50% -- off' contains a comment marker. The parser here tracks whether it is inside a quoted string and only strips comments outside one, including handling doubled quotes as an escaped quote rather than a terminator.
Does it remove line breaks inside string literals?
No. Anything between quotes is left exactly as written, because changing it would change the data the query inserts or compares against.