SQL Formatter

Format and minify SQL queries with dialect support.

The SQL Formatter reformats or minifies SQL queries with dialect support for standard SQL, MySQL, PostgreSQL, SQLite, T-SQL, Oracle and BigQuery. You choose indentation and whether keywords are uppercase, lowercase or preserved. It helps developers read machine-generated queries and keep code reviews tidy.

What is SQL formatting?

SQL formatting rearranges a query into a consistent layout, with clauses such as SELECT, FROM, WHERE and ORDER BY on their own lines, columns listed one per line and joins indented. The meaning of the query does not change; only whitespace and, optionally, the case of keywords. Different databases use different syntax, for example quoting identifiers with backticks in MySQL, square brackets in T-SQL or double quotes in PostgreSQL, so a formatter needs to know the dialect to tokenize correctly. Minifying does the opposite: it removes comments and collapses whitespace.

How to use SQL Formatter

  1. Enter SQL Type or paste a query into the SQL box.
  2. Pick options Set Dialect, Mode (Format or Minify), Indent and Keywords.
  3. Run it Press Format SQL; the Result pane shows the output.
  4. Export Copy the result or download it as query.sql.

Frequently asked questions

Does formatting change what the query does?

No. Only whitespace and, if you choose, keyword case change. String literals and quoted identifiers are left alone.

Why select a dialect?

Dialects differ in quoting, operators and functions. Choosing the right one lets the formatter tokenize those correctly instead of failing.

Does Minify remove comments?

Yes, both -- line comments and /* */ block comments are removed, and whitespace outside quotes is collapsed.

Can it format several statements?

Yes. Multiple statements separated by semicolons are formatted together.

Does it validate against my database?

No. It only checks syntax well enough to format; it does not know your tables or run the query.