SQL Formatter

Uppercase keywords, one clause per line, indented subqueries. Dialect-agnostic.

Formatted
—

Worked example

Formatting does not change execution, but it changes review. A query that fits on one line is read as "some SQL"; the same query with clauses on separate lines is read as a set of decisions about joins and filters.

SQL does not care about whitespace, which is exactly why formatted SQL is a communication tool rather than a syntax requirement. The value is in review: a diff of a formatted query shows the clause that changed, not the whole line.

Dialect caveats

This is a keyword-driven formatter, not a parser. It will not understand dialect-specific syntax such as Postgres :: casts or T-SQL TOP, and it will not reorder or validate anything. For anything structural, use your database's own EXPLAIN output.