SQL Formatter & Minifier Online

Local processing

Expand dense queries into readable SQL with selectable dialect and keyword casing, or compress them again.

75 chars · 1 line

Waiting for input

Loading SQL formatter…

SQL formatting guide

How to format and minify SQL

Turn dense SQL into an indented, readable query, choose a target dialect and keyword casing, or collapse unnecessary whitespace for compact storage. Formatting and minification run entirely in your browser, and quoted values and comments remain part of the result. This tool is free to use. No account or payment is required.

Last updated

What you can do here

  • Readable SQL formatting
  • Generic SQL, PostgreSQL, MySQL, and SQLite formatting
  • Preserve, uppercase, or lowercase keyword casing
  • Whitespace minification
  • Quoted string and identifier preservation
  • Line and block comment preservation
  • PostgreSQL dollar-quote support
  • Browser-local processing

How to use

  1. Paste a SQL statement into the input editor.
  2. Choose Format for readable indentation, then select the SQL dialect and whether keywords keep their original case, become uppercase, or become lowercase; choose Minify for compact whitespace.
  3. Review quoted values, comments, and database-specific syntax in the output.
  4. Copy or download the resulting SQL text.

Make dense SQL easier to review

Format mode adds line breaks and indentation around common SQL clauses, columns, conditions, joins, and ordering expressions. This helps with code review, debugging, and documenting generated queries.

Choose Generic SQL, PostgreSQL, MySQL, or SQLite parsing, and optionally normalize recognized keywords to uppercase or lowercase. Preserve case remains the default so existing formatting behavior does not change unless you choose it.

Formatting changes presentation rather than the intended query values.

Quoted text and comments are preserved

Minify mode collapses whitespace outside protected regions while retaining line comments, block comments, and content inside single quotes, double quotes, backticks, square-bracket identifiers, and PostgreSQL dollar-quoted blocks.

  • Whitespace inside string literals is not collapsed.
  • Escaped and doubled quote characters stay with their quoted value.
  • PostgreSQL #>, #>>, and #- operators are not mistaken for comments.

Formatting is not SQL validation

The formatter does not connect to a database, execute the query, optimize a plan, or guarantee that every vendor-specific statement is valid. Always test production SQL against the target database and dialect.

SQL formatting example

A compact SELECT statement becomes easier to scan while the quoted status value remains unchanged.

SQL input

select id,name from users where status = 'active' order by created_at desc;

Formatted output

SELECT
  id,
  name
FROM
  users
WHERE
  status = 'active'
ORDER BY
  created_at DESC;

Common questions

Frequently asked questions

Does SQL minification remove comments?

No. The minifier removes unnecessary whitespace outside protected regions but keeps line and block comments in the output.

Which SQL dialect does the formatter use?

Format mode supports Generic SQL, PostgreSQL, MySQL, and SQLite selections. The chosen dialect guides parsing and formatting, but vendor-specific statements still need review against the database that will execute them.

Does formatting execute or validate the SQL?

No. The tool only transforms text and never connects to a database or verifies the execution plan.

Is the SQL query uploaded?

No. Formatting and minification run locally in your browser.

Looking for broader references? Browse all developer guides.