SQL prettify and format

Format and prettify your SQL queries online (it supports various SQL dialects).

About SQL prettify and format

Formats SQL into a consistently indented, readable layout, with the dialect of your database (PostgreSQL, MySQL, SQL Server, BigQuery and more), keyword casing and indent style of your choice. Powered by the sql-formatter library.

When you would use it

How to use it

  1. Choose the dialect that matches your database so its specific keywords and syntax are recognised.
  2. Pick the keyword case (UPPERCASE, lowercase or preserve) and the indent style.
  3. Paste the query and copy the formatted result.

Things worth knowing

Frequently asked questions

Why does the output look wrong around a specific construct?
Most likely the dialect does not match. Switch to the dialect of your database; if the construct is unusual, Standard SQL may format it more predictably.
Does formatting change how the database executes the query?
No. Whitespace and keyword case are irrelevant to the database. String literals and identifiers are left untouched, so the query behaves exactly the same.

All the tools