Format messy SQL with the open-source sql-formatter engine: pick your dialect, keyword casing and indent style.
Formatting happens locally in your browser. Your queries never leave your device.
Formatting is done by sql-formatter, the same open-source (MIT) library this page bundles from npm. It runs in three steps: a dialect-specific tokenizer splits your query into keywords, identifiers, strings and operators; a lightweight parse pass infers clause structure (what is a SELECT list, what is nested inside a CASE); and a layout writer re-emits the tokens one clause per block with your indent and casing. No database is involved at any point.
No — it never touches a database. The formatter reads your query as plain text, rewrites whitespace and keyword casing, and shows you the result. Your statements, table names and data stay on your device, and there is no connection to configure or attempt.
Not on this page. The underlying sql-formatter library (v15, same as npm's current release) is a pretty-printer: it lays queries out, it does not compress them. Older versions had a minified mode; it was removed upstream. For shrinking minified-on-purpose statements, our Code Minifier tool covers SQL-adjacent text as a separate job.
Only incidentally. sql-formatter is a tokenizer plus layout engine, not a validator: it does not check your schema, function names or even full grammar compliance, and most malformed-but-tokenizable text still formats. It does fail on genuinely unterminated constructs (like an unclosed string literal), and that error is surfaced in the error line.
Each dialect ships its own keyword list and token rules, so the same text can be segmented differently: BigQuery treats struct literals and @params specially, PostgreSQL knows ::casts, MySQL accepts backtick identifiers. Pick your actual engine before formatting — casing and line breaks follow the dialect's tokenizer.
No. The formatter is a JavaScript module bundled with this page and running in your browser (sql-formatter, MIT licensed). Your queries never leave your device — which matters, because queries often contain credentials and customer data.
If you just finished with SQL Formatter, the natural next steps are Data Size Converter, JSON Formatter & Validator, JSON to YAML Converter, or browse every tool in Privacy File Tools.