All tools

SQL formatter

Minified one-line SQL from ORM logs and copy-paste is hard to review. Pretty-print with keyword capitalization and nested indent for JOINs, CTEs, and subselects — before code review or documentation. Formatting runs locally so production queries with table names stay private.
Input

How to format SQL

1. Paste SQL query into editor.
2. Choose dialect hints if available (MySQL, PostgreSQL, Standard).
3. Click format.
4. Copy indented SQL for wiki or slide.

SQL formatting examples

Nested JOIN

SELECT with three LEFT JOINs indented per clause — spot missing ON condition faster.

CTE readability

WITH sales AS (...) main query separated visually from CTE block.

INSERT batch

Multi-row VALUES aligned column-wise for diff review.

When to format SQL

When sharing queries in pull request comments.
When learning SQL structure from generated ORM output.
When documenting report queries for BI team.

When formatter may fail

When SQL mixes vendor-specific syntax formatter does not know — expect imperfect layout.
When formatting changes string literal whitespace meaning — rare but check.
When query is PL/pgSQL procedural block — use dialect-specific tools.

Readable SQL in reviews

Reviewers catch missing WHERE tenant_id filter faster on indented SQL — security win beyond aesthetics.

ORM round trip

Log formatted SQL to correlate Sequelize/Hibernate output with hand-written optimized version.

Parameter placeholders

? and $1 styles preserved — do not confuse formatter with prepared statement binding.

Frequently asked questions

Which SQL dialect?

Generic formatters handle ANSI-ish SQL; MySQL backticks vs Postgres quotes differ.

Uppercase keywords?

Common style SELECT FROM WHERE — preference not requirement.

Validate syntax?

Formatting ≠ execution — run EXPLAIN in database for real validation.

Sensitive data?

Local format avoids SaaS leak — still redact PII in literals before sharing screen.

Minify SQL?

Remove newlines manually for embedded queries — opposite of format.

Large scripts?

Megabyte migration files may slow browser — format sections individually.