SQL Formatter

SQL formatter & beautifier

Paste a cramped, one-line query and get clean, indented SQL with consistent keyword casing — instantly and privately.

▌ SQL in
▌ Formatted

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 FROM and JOIN lines first to see which tables are involved and how they relate, then the WHERE clause for what is filtered.
  • Check every JOIN has an ON condition — a missing one produces a cross join and an enormous result set.
  • Look for filters on the outer table of a LEFT JOIN sitting in WHERE rather than ON, 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.

FAQ

Does my SQL get sent to a server?
No. The formatter runs entirely in your browser, so the query you paste never leaves your device — safe for real table names and values.
Can it change keyword capitalisation?
Yes. Pick UPPERCASE or lowercase to normalise SQL keywords like SELECT and WHERE, or choose 'keep as typed' to leave your casing untouched.
Does formatting change how my query runs?
No. SQL treats runs of whitespace outside string literals as a single separator, so re-indenting cannot change the result. The formatter only adjusts whitespace and keyword casing — it never reorders clauses or alters identifiers and values.
Should SQL keywords be uppercase?
It makes no difference to the database, since keywords are case-insensitive. The convention is for readability: uppercase keywords make the structure of a query stand out from your own table and column names, which speeds up review.
Is my SQL uploaded anywhere?
No. The formatter runs entirely in your browser, so the query never leaves your device. That matters because real queries often contain table names, column names and literal values you would not want to paste into a third-party service.

Related tools