SQL Formatter for PostgreSQL, MySQL & SQLite

Paste a query — it formats as you type. Puts clauses on their own line, numbers lines, adjusts indent, and can minify back to a single line — without disturbing strings, comments, placeholders, CTEs or window functions. Tokenizer-based, no server round-trip, with a before/after diff to prove nothing was lost.

Input

{{ num }}
Waiting for input… Tokenized as {{ dialect }}
Output
Keywords Indent
{{human(origSize)}} → {{human(outSize)}} · {{deltaLabel}} · {{outLineCount}} lines · ✓ same tokens as the input — only whitespace and casing changed ⚠ {{ fidelity.changes.length }} token{{ fidelity.changes.length===1?'':'s' }} differ from the input — see Before/after diff
{{ num }}

Token-level check found {{ fidelity.changes.length }} discrepanc{{ fidelity.changes.length===1?'y':'ies' }} between the input and the output — not just reformatted, something was actually added or removed. Listed below with the surrounding lines for context.

Every keyword, identifier, string, comment and placeholder in the input is present in the output, in the same order — this diff is whitespace/line-break/casing only.

{{ row.kind === 'added' ? '+' : row.kind === 'removed' ? '−' : ' ' }} {{ row.text || ' ' }}
About this tool

A tokenizer splits the query into keywords, identifiers, strings, comments and placeholders, then a formatter reflows it — one clause per line, consistent indent — or collapses everything back to a single line for minify. The Before/after diff tab re-tokenizes its own output and checks it against the input token-for-token, so you can confirm nothing was silently added, dropped, or reordered — not just eyeball two blocks of SQL.

Dialect affects keyword highlighting/vocabulary (e.g. ILIKE for PostgreSQL, # comments for MySQL) and a couple of lexical rules that differ by engine (backslash string-escaping, nested block comments). It recognizes a fixed keyword list — it doesn't parse a grammar, validate syntax, or connect to a database, so "tokenized" is not "valid SQL."

Formatting runs entirely in your browser. Your query is never sent anywhere.