SQL formatter & beautifier
Paste a cramped, one-line query and get clean, indented SQL with consistent keyword casing — instantly and privately.
Readable SQL, instantly
Queries have a way of growing into long, unbroken lines that are painful to read and review. This formatter puts each major clause — SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY — on its own line, indents subqueries, breaks long column lists, and normalises keyword casing, so the structure of a query becomes obvious at a glance. Choose uppercase, lowercase, or leave keyword casing as you typed it.
Private and quote-aware
Everything runs in your browser; your SQL is never uploaded, which matters when queries contain table names or values you'd rather not paste into a random website. The formatter is aware of quoted strings and comments, so a comma or keyword inside 'a, b' won't be mistaken for query structure. For very complex statements — deeply nested CTEs, vendor-specific syntax — it's a fast first pass; always give the result a quick read before running it.
Formatting never changes what a query does
Outside of string literals, SQL treats runs of whitespace and newlines as a single separator, so re-indenting a query cannot alter its results. The formatter only moves whitespace and, if you ask it to, changes the case of keywords — it never reorders clauses, rewrites joins or touches your identifiers and values.
That matters when you are formatting a query you are about to run against production: the statement you get back is semantically identical to the one you pasted. If the output ever behaves differently, that is a bug in the formatter, not an optimisation it applied.
Why keyword casing is worth settling
SQL keywords are case-insensitive, so select and SELECT are the same token. The convention of uppercasing keywords exists purely for humans: it makes the skeleton of a query — the clauses — visually distinct from your own table and column names, which is exactly what you scan for when reviewing.
Identifiers are a different matter and casing there can be significant. Quoted identifiers are case-sensitive in PostgreSQL, and unquoted ones are folded to lower case, whereas MySQL's behaviour for table names depends on the filesystem. The formatter deliberately leaves identifiers alone for that reason — only keywords are recased.
Reading a formatted query
Once each clause sits on its own line, a few habits make review much faster:
- Read the
FROMandJOINlines first to see which tables are involved and how they relate, then theWHEREclause for what is filtered. - Check every
JOINhas anONcondition — a missing one produces a cross join and an enormous result set. - Look for filters on the outer table of a
LEFT JOINsitting inWHERErather thanON, which quietly turns it into an inner join. - With indentation visible, confirm each subquery returns the shape the surrounding clause expects.
For syntax itself, the SQL commands cheat sheet covers the statements and clauses with examples.