Loading the interactive tool… It runs in your browser — if it doesn't appear, enable JavaScript.
Paste a query and get it formatted with each clause on its own line, joins and conditions indented, and keywords cased consistently. Or minify it down to a single line for embedding in code.
The query is tokenised before anything is reformatted, which matters more than it sounds: string literals and comments are left completely untouched. Regex-based formatters routinely uppercase a word inside a quoted value or break a line in the middle of a literal, silently changing what the query does. Clause breaks also respect bracket depth, so subqueries stay intact rather than being torn apart at the top level.
Frequently asked questions
Which SQL dialects are supported?
The formatting is dialect-agnostic and works on standard SQL keywords, so PostgreSQL, MySQL, SQLite, SQL Server and Oracle queries all format sensibly. It doesn't parse dialect-specific syntax deeply, so unusual vendor extensions are passed through unchanged rather than rearranged.
Is my query sent to a server?
No — formatting happens entirely in your browser. Worth caring about, since a real query contains your table names, column names and often literal values from production data.
Will formatting change what my query does?
No. Only whitespace and keyword casing change, and neither is significant in SQL outside of string literals — which are deliberately left alone. Minifying additionally strips comments, so keep the original if the comments matter.