Skip to content
SQL → Minified / Formatted SQLDeveloper tools

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.

Did this tool work for you?

Used SQL Minifier & Formatter? Share how it went to help others.

About this tool

About SQL Minifier & Formatter

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.

SQL Minifier & Formatter tool

Who minifies SQL

Compact for code, clear for people

Embedding in code

Put a query in one line of application code.

ExampleA 20-line report query becomes one line for a Python string.

Logs and command lines

Pass a query to a CLI or store it in a log.

ExampleA query is minified to paste into a mysql -e command.

Reading someone’s query

Format a one-line query from logs to understand it.

ExampleA slow query from the database log is formatted to spot a missing WHERE.

Learning SQL

See the structure of a query clearly.

ExampleA student formats a JOIN query to see each clause.

Code reviews

Share consistently formatted SQL.

ExampleQueries are formatted with uppercase keywords before a pull request.

Smaller payloads

Trim large migration or seed files.

ExampleA 40 KB seed script is minified by about a third.

SQL tips

Readable and safe

Keep formatted SQL in source control

Store queries formatted so changes are easy to review; minify only where size or one-line format matters.

Never build SQL from user input

Use parameterised queries in your code. Minifying does not protect against SQL injection.

MySQL uses # comments

Turn on MySQL # comments if your file uses them, so they are removed correctly.

Format before debugging

A formatted query shows a missing JOIN condition or WHERE clause much faster.

Need a full formatter?

For more layout options, use the SQL Formatter.

Open SQL Formatter

Working with JSON results?

Format query results exported as JSON with the JSON Formatter.

Open JSON Formatter
Built & tested by

HemantInsights

Senior 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

Answers and guidanceFrequently Asked Questions
What does minifying SQL do?
It removes comments and extra whitespace so the query takes less space, without changing what it does.
Will minifying break my strings?
No. Text inside quotes, quoted names and dollar-quoted blocks are left exactly as written.
What happens to comments?
They are removed by default. With Keep comments, line comments become /* */ comments so a one-line query still works.
Can it format SQL too?
Yes. Format mode puts each clause on its own line and indents subqueries.
Which databases does it support?
Standard SQL used by MySQL, PostgreSQL, SQL Server, SQLite and Oracle, including backticks, brackets and $$ blocks.
Can I uppercase keywords?
Yes. Turn on UPPERCASE keywords in either mode.
Does it validate my SQL?
No. It changes layout only; your database checks the syntax when the query runs.
Is my SQL uploaded?
No. Everything runs in your browser.
Can I open a .sql file?
Yes. Open it with the button above the editor.
Is it free?
Yes, free with no sign-up.
More tools for your workflowRelated Tools

Featured on

Toolyconvert is listed on these product directories and launch platforms.