Skip to content

SQL Formatter

Format SQL queries with consistent keyword casing and indentation.

Formatted SQL

Paste a query on the left.

About SQL Formatter

A long query written on one line is almost impossible to review. Putting each major clause on its own line and indenting nested expressions turns the same query into something you can read top to bottom.

This formatter upper-cases keywords, breaks before the major clauses, indents parenthesised subqueries, and leaves your literals and comments untouched.

Frequently asked questions

Which SQL dialects are supported?

The formatter is dialect-agnostic. It recognises standard clauses and operators shared by PostgreSQL, MySQL, SQL Server and SQLite.

Will it change my query?

No. Only whitespace and keyword casing change; string literals, identifiers and comments are preserved exactly.

Does it handle subqueries?

Yes. Nested parentheses increase the indentation level, so common table expressions and subqueries stay readable.

Related tools