SQL Minifier
Minify SQL by removing comments and extra whitespace, keeping strings and optional optimizer hints. Shows the size saved. Free, in your browser.
About SQL Minifier
The SQL Minifier compresses a query by removing comments and extra spaces and line breaks, handy for SQL kept in code strings, logs or tickets. It shows how much smaller it got.
Strings are untouched
Text inside quotes keeps every space and doubled apostrophe exactly.
Optimizer hints
Keep optimizer hints is on by default, so special /*+ */ comments your database reads are not stripped.
No rewriting
Only comments and white space go; the SQL itself is not changed or checked.
Need it readable again?
Use the SQL Formatter.
Private
Everything runs in your browser. Nothing you paste is uploaded.
How to use SQL Minifier
- Paste your SQL or open a file.
- Tick or untick Keep optimizer hints.
- Read the minified SQL and the size saved.
- Copy it or download a .sql file.
Help & FAQ
What does the SQL Minifier do?
It removes comments and extra white space from SQL and shows how many bytes were saved.
Does it change text inside quotes?
No. In the test strings in single and double quotes kept their spaces and doubled apostrophes.
What are optimizer hints?
Comments such as /*+ INDEX(t i) */ that guide the database. MySQL also runs /*! ... */ version comments.
Should we keep optimizer hints?
Usually yes. Removing a hint can change the query plan, and MySQL executes /*! */ comments, so leave the option on unless you know otherwise.
How much smaller does SQL get?
In the test a short query went from 137 B to 107 B, 22 percent. The saving depends on your indentation and comments.
Does it remove line comments?
Yes. A -- comment was removed so it cannot hide the rest of the query once everything is on one line.
Does it validate our SQL?
No. It does not parse the query for correctness. It only removes comments and spacing.
Does it keep semicolons?
Yes. Statements stay separated by semicolons.
Can it make our query faster?
Not in any real way. A database reads minified and formatted SQL the same way.
How can we read the result again?
Paste it into the SQL Formatter, or press Use result as input to continue working on it.
Is there an example?
Yes. Press Load example for sample SQL.
Is our SQL uploaded?
No. The minifying runs in your browser.