Dialect
Indent
SQL Input
Formatted SQL

What is a SQL formatter?

A SQL formatter rewrites a query with consistent indentation, one clause per line and uppercase keywords. You use it to read a long query from a log or an ORM, to review a query in a pull request, or to tidy SQL before you save it in a migration.

How to format SQL

  1. Paste your SQL into the SQL Input pane, or click Sample.
  2. Select the Dialect and the Indent.
  3. Turn Uppercase keywords on or off.
  4. Read the result in Formatted SQL and click Copy.

What the formatter changes

The column list indents under SELECT. Each JOIN starts a new line, and AND and OR conditions indent one level. Strings, numbers and comments stay as they are, so the query does the same thing after formatting.

Frequently Asked Questions

Which SQL dialects does the formatter support?

Standard SQL, MySQL and PostgreSQL. The indentation rules are the same for all three.

Can it format stored procedures?

Simple procedures format well. Long PL/pgSQL or T-SQL blocks with DECLARE, BEGIN and END can indent imperfectly, because the formatter works from keywords and is not a full parser.

Can I format several statements at once?

Yes. Separate the statements with semicolons and paste them together. Each statement formats on its own.

Why are my keywords not uppercase?

Turn on Uppercase keywords in the toolbar. It is on by default.

Is my SQL sent to a server?

No. Formatting runs in your browser. Your SQL stays on your device.