Skip to content
Tools

SQL Formatter

Format SQL with clause breaks, indentation and keyword casing.

Local
Formatted SQL

What this tool does

This tool reformats a SQL statement to make it readable: each major clause on its own line, each selected column on its own line, conditions broken out, subqueries indented, and keywords optionally upper-cased. It formats the SQL; it does not run or validate it.

How it formats

  • Clauses such as SELECT, FROM, WHERE, JOIN, GROUP BY and ORDER BY start a new line.
  • Items in a select list are placed one per line; commas inside a function call stay inline.
  • AND and OR are broken onto their own lines under the condition.
  • A subquery in parentheses is indented; a function call stays tight.

Good to know

The formatter works on the structure of the statement, so it handles the common shapes of SELECT, INSERT, UPDATE and DELETE. It does not understand every dialect or every vendor extension, and it does not check that your SQL is valid. Strings and comments are left exactly as written; only layout and keyword case change.

Common use cases

  • Making a long query from a log or an ORM readable before you review it.
  • Tidying SQL for a pull request or documentation.
  • Standardising keyword case across a team's queries.

Frequently asked questions

Does it run or validate the SQL?
No. It only reformats the text in your browser. It does not connect to a database, run the query or check that it is valid.
Which dialects are supported?
It handles the common shapes of SELECT, INSERT, UPDATE and DELETE across dialects. It does not understand every vendor extension, and strings and comments are left exactly as written.

Learning resources

Testsmith also runs hands-on courses and a free practice app for the skills behind this tool.

Feedback welcome

Found a bug in this tool, or want it to do something it does not? Tell us and we will take a look.