SQL Formatter

Paste a query from an ORM log or a slow-query report and get it laid out clause by clause, in your database’s dialect.

Input · drop a file

Output

How the SQL is laid out

  • Each major clause (SELECT, FROM, JOIN, WHERE, GROUP BY…) starts a new line.
  • Column lists and conditions are indented one per line.
  • Keywords can be UPPER, lower or left as typed.
  • Multiple statements are separated by a blank line.

Why pick a dialect

Databases disagree on details — PostgreSQL’s :: casts and $1 parameters, MySQL’s backtick identifiers, SQL Server’s [brackets] and TOP, BigQuery’s backtick table paths. The right dialect keeps these intact.

Formatting never changes what the query does; only whitespace and keyword case change.

Questions

Does it check that my SQL is valid?

It tokenises the query and reports clearly broken syntax, but it does not know your tables. A formatted query can still fail if a column doesn’t exist.

Can it format stored procedures?

Yes for common procedural syntax; pick PL/SQL for Oracle or Transact-SQL for SQL Server.

Can I minify SQL too?

Yes — press Minify, or use the SQL minifier page, which strips comments and collapses the query onto one line while keeping strings intact.

Is SQL Beautifier the same thing?

Yes — “SQL beautifier” and “SQL formatter” describe the same tool.

Related tools