SQL Formatter: Beautify and Minify SQL Queries

Paste a SQL query to format it with clean indentation, or minify it. Choose a dialect, keyword case and list style.

Loading tool…

How to use the SQL Formatter

  1. Paste your SQL or upload a .sql file.
  2. Choose Beautify or Minify, the dialect (standard, MySQL, PostgreSQL, SQL Server, Oracle) and the indent.
  3. Pick keyword, function and identifier case, and comma-first lists if you like.
  4. Check any warning about unbalanced brackets or quotes, then copy or download the result.

About this tool

A formatter makes long queries readable: each major clause (SELECT, FROM, WHERE, GROUP BY, ORDER BY) starts on its own line, columns are listed one per line (or comma-first), joins and AND/OR conditions are indented, subqueries and CTEs in parentheses are indented one level deeper, and CASE expressions and window functions stay on one line. Strings, quoted identifiers and comments are left untouched; only whitespace and letter case change.

The dialect setting changes how text is read: MySQL allows backslash escapes in strings, # comments and double-quoted strings; PostgreSQL keeps $$ ... $$ bodies exactly as written; SQL Server reads [bracket] names. Keyword case can be upper, lower or as typed, and function names can be cased separately. Changing the case of unquoted table and column names can break case-sensitive databases, so that option is off by default.

Minify removes comments and extra whitespace to put the query on one line; do not minify queries whose comments carry optimizer hints. The tool is a formatter, not a SQL parser: it warns about unbalanced parentheses and unclosed quotes or comments but does not check that the query is valid, and stored procedures, PL/SQL blocks and CREATE FUNCTION bodies may format loosely. There is no line-width wrapping.

Frequently asked questions

Does formatting change what my query does?

No. Only whitespace and letter case change. String values, quoted identifiers and comments stay as written.

Which SQL dialects work?

Standard SQL plus MySQL/MariaDB, PostgreSQL, SQL Server and Oracle quoting rules. Common SELECT, INSERT, UPDATE and DELETE statements, CTEs, CASE and window functions format well; procedural code may not.

Does it validate my query?

Only for unbalanced brackets and unclosed quotes or comments. It does not run or fully parse the SQL.

Is my query uploaded?

No. The formatting happens in your browser and nothing is sent to a server.

Why are my comments missing after minify?

Minify removes comments on purpose. Use Beautify if you want to keep them.

Need a custom tool or website?

IDM Valley builds web apps, calculators, AI chatbots and automation for businesses. Fixed prices, code in your name.

Get a free quote

Have a project in mind?

Tell us what you need: a website, landing page, AI chatbot or automation. You get a clear scope and a fixed price within one working day. Free, no obligation.


  • avshack
  • DivineBamboo
  • goldleaf
  • janapril
  • kaizen
  • kwc
  • modv
  • pixelrush
  • revital
  • riderzplanet
  • sandsfashions
  • avshack
  • DivineBamboo
  • goldleaf
  • janapril
  • kaizen
  • kwc
  • modv
  • pixelrush
  • revital
  • riderzplanet
  • sandsfashions