SQL Minifier & Formatter
Minify SQL into one compact line or format it for reading. Strings, quoted names and comments are handled safely, with keyword uppercasing and size savings.
Minify SQL into one compact line or format it for reading. Strings, quoted names and comments are handled safely, with keyword uppercasing and size savings.
Used SQL Minifier & Formatter? Share how it went to help others.
About this tool
SQL Minifier shrinks SQL queries by removing comments and extra whitespace, and the Format mode does the opposite, laying a query out clearly. Paste SQL or open a .sql file. Minify removes -- line comments and /* */ block comments (MySQL /*! */ hints are kept), collapses spaces, tabs and line breaks, and drops spaces around commas, brackets and comparison operators, so a long query fits on one line for code, logs or a URL. It is built on a small tokenizer rather than simple find-and-replace, so the meaning of the query never changes: text inside quotes, such as 'it''s -- not a comment', is left exactly as written, as are double-quoted, backtick and bracketed names and PostgreSQL dollar-quoted function bodies. It also never creates a comment by accident: “a - -1” keeps its space, because two minus signs together would start one. Keep comments turns line comments into block comments so a one-line query still works, and One statement per line keeps each statement on its own line. Format mode starts each main clause, SELECT, FROM, WHERE, GROUP BY, ORDER BY, LIMIT, JOINs, INSERT and VALUES, on a new line, indents subqueries, and writes function calls as COUNT(*) and keyword brackets as IN (…). In both modes you can write keywords in UPPERCASE, and turn on MySQL # comments. The size before and after and the percentage saved are shown, together with the number of statements. Copy the result or download it as a .sql file; your SQL stays in your browser.

Paste a query or open a .sql file.
Compact one-liner, or a clean layout for reading.
Uppercase keywords, keep comments, one statement per line, MySQL #.
See the size saved, then copy or save a .sql file.
Strings, names and $$ blocks never changed.
Clauses on new lines, indented subqueries.
Remove, or keep as safe block comments.
Consistent style in one click.
Compact for code, clear for people
Put a query in one line of application code.
ExampleA 20-line report query becomes one line for a Python string.
Pass a query to a CLI or store it in a log.
ExampleA query is minified to paste into a mysql -e command.
Format a one-line query from logs to understand it.
ExampleA slow query from the database log is formatted to spot a missing WHERE.
See the structure of a query clearly.
ExampleA student formats a JOIN query to see each clause.
Share consistently formatted SQL.
ExampleQueries are formatted with uppercase keywords before a pull request.
Trim large migration or seed files.
ExampleA 40 KB seed script is minified by about a third.
Readable and safe
Store queries formatted so changes are easy to review; minify only where size or one-line format matters.
Use parameterised queries in your code. Minifying does not protect against SQL injection.
Turn on MySQL # comments if your file uses them, so they are removed correctly.
A formatted query shows a missing JOIN condition or WHERE clause much faster.
Format query results exported as JSON with the JSON Formatter.
Open JSON FormatterSenior Software Engineer · Developer of Toolyconvert
Hemant developed SQL Minifier & Formatter and tests it on desktop and mobile with real files. He is a senior software engineer from Dehradun, India, building websites since 2014, and designed and developed Toolyconvert end to end.
Last updated 12 November 2026
Featured on
Toolyconvert is listed on these product directories and launch platforms.