SQL Formatter

Beautify SQL Queries Online.

Loading…

A query copied out of a log or an ORM arrives as one line 400 characters wide. Before you can debug it you have to see its shape: what is selected, which tables are joined, where the conditions are.

Paste it here. Each clause starts on its own line, selected columns are listed one per line, AND and OR conditions are indented under WHERE, and subqueries step in a level. Keywords can be capitalised or left lower case.

How to use the SQL Formatter tool

  1. Paste your SQL.
  2. Choose the indent and the keyword case.
  3. Copy the formatted query or download it.
  • Reading a long query from an application log
  • Tidying SQL before a code review
  • Making queries in documentation consistent

Tips for the best result

  • Strings and comments are never changed, so data inside quotes is safe.
  • Several statements separated by semicolons are formatted one after another.

Quick facts

PriceFree
Works withSQL
Where it runsIn your browser, on your device
AccountNot needed

Frequently asked questions

Which SQL dialects does it handle?

The common core of MySQL, PostgreSQL, SQLite, SQL Server and Oracle. Vendor-specific procedure code is left mostly as it is.

Does it check whether my SQL is valid?

No. It arranges the text and does not run or validate the query.

Is my query sent to a server?

No. Formatting happens in your browser, so table names and data in the query stay with you.

Will it change what the query does?

No. Only spaces, line breaks and keyword case change.