SQL Minifier
NewMinify SQL queries by stripping comments and collapsing whitespace, while carefully preserving the exact contents of string literals.
Strips -- line comments and /* ... */ block comments, then collapses all remaining whitespace runs to a single space — while leaving the contents of single-quoted string literals completely untouched, so comment-like text inside a string is never accidentally removed.
Frequently Asked Questions
Does this change what my query actually does?
No — it only removes `--` line comments, `/* ... */` block comments, and collapses whitespace runs to single spaces; the query's logic, table names, column names, and conditions are left completely untouched.
What happens to comment-like text inside a string literal?
It's left completely alone — the minifier tracks single-quoted string boundaries (including the standard `''` escaped-quote convention) so anything inside a string, even if it looks like `--` or `/*`, is never mistaken for an actual comment.
Why would I want to minify a SQL query at all?
Minified SQL is useful when embedding a query as a single-line string in application code, logging it compactly, or reducing the size of a query sent over the wire in contexts where every character counts, such as some URL-based query parameters.
Will this work with any SQL dialect (MySQL, PostgreSQL, SQL Server)?
Yes — the comment syntax it strips (`--` and `/* */`) and the whitespace-collapsing logic are common to essentially all major SQL dialects, since it doesn't need to understand dialect-specific keywords or functions to do its job.
Is there a way to reverse this and pretty-print the SQL again?
Yes — use the separate SQL Formatter tool on this site to re-indent and reformat a minified (or any) SQL query back into a readable, multi-line layout.