Skip to tools
3 min read·

Why you should format your SQL (and how)

Nicely formatted SQL is easier to review, easier to debug and easier to optimise. Here is the playbook.

SQL Formatting

The case for consistent SQL

Compressed SQL that fits on one line is fine for a machine but brutal for humans. Uppercasing keywords, breaking after each clause and indenting subqueries makes long queries scannable in seconds and catches subtle bugs (missing joins, unfiltered updates) that hide in dense text.

What our formatter does

The SQL Formatter uses sql-formatter under the hood with keyword case set to upper and a two-space indent. It handles PostgreSQL, MySQL, SQL Server, BigQuery, SQLite and Redshift dialects, and it preserves your comments so review notes survive.

Pair it with the Diff Checker

Format two versions of a query and drop them into the Diff Checker to see exactly what changed — including whitespace — before you ship a migration.

Try it in Code Formatter Pro

Every tool mentioned in this article runs entirely inside your browser — no signup, no uploads.

Open the toolkit