Compress multi-line SQL into a single line and strip comments locally.
Output
SELECT id, name AS user_name, email FROM users WHERE notes <> 'a -- string with dashes' AND created_at > NOW() - INTERVAL '7' DAY;
Common tasks
SQL minifier
SQL one line
remove SQL comments
compress SQL online
Quick answer
Remove SQL comments and optionally collapse whitespace in the browser. The scanner recognises single, double and backtick quotes while finding comments; it is not a dialect parser, validator or query optimizer. Review the output before executing it.
How to use
1. Paste a copy of the SQLKeep an original copy. The tool does not connect to or execute against a database.
2. Choose the two optionsEnable Remove comments to strip --, # and /* … */ comments. Enable Compress to one line only when whitespace is not significant.
3. Run and inspectRun the transformation and compare literals, comments and statement boundaries with your source before copying the result.
Examples
Remove comments and compress
Input
-- list users
SELECT id, name /* display */ FROM users;
Output
SELECT id, name FROM users;
Keep comment-like text inside a literal
Input
SELECT 'a -- b' AS note; -- explanation
Output
SELECT 'a -- b' AS note;
Both options enabled; the spaces inside this example are already single spaces.
Common use cases
Make a short query easier to paste into a text field
Remove explanatory comments from a review copy
Edge cases
Single-line mode collapses whitespace everywhere, including inside quoted strings. Disable it when spaces or line breaks inside literals must be preserved.
Do not combine retained -- or # line comments with single-line output: removing the newline can turn subsequent SQL into part of the comment.
Dollar-quoted strings, bracket-quoted identifiers, nested comments and dialect-specific operators are not fully understood. Removing comments can also remove optimizer hints or MySQL executable comments.
Features
Minify SQL by removing comments and redundant whitespace
Optional single-line output
Strips both -- line comments and /* block */ comments
No. It uses a lightweight scanner and does not validate a database dialect or prove equivalent query behavior.
Can I preserve all formatting?
Turn off both Remove comments and Compress to one line to return the input unchanged. Turn off only single-line mode to keep whitespace while removing comments.