How to minify a SQL query
Minifying SQL collapses a formatted query onto one line and removes its comments. It is a packaging step: it makes a statement fit into a config value, a log line, or a single string in code, and it has no effect at all on how the database executes it.
The transform runs in your browser as a text pass. Because it is not a SQL parser, it cannot tell a comment marker inside a string literal from a real comment, so it is worth diffing the output against the input before you use the result.
- Paste the formatted SQL query into the input box.
- Read the single-line output, with comments removed and whitespace collapsed.
- Diff the output against the input, especially if any string literal contains a double dash or a slash-star sequence.
- Copy the one-line query into your config file, log statement, or code.
- Keep the formatted version as the one you maintain, because a single-line query is far harder to debug when the database reports an error position.