SQL Formatter and Beautifier
Re-prints a query with one clause per line, consistent keyword case and readable indentation.
Loading the tool…
How to use this tool
- Paste your SQL, or drop a .sql file onto the box.
- Choose the indentation, keyword case and comma position your team uses.
- Select Format, then copy or download the result.
What sql formatter does
A SQL formatter rewrites the whitespace and keyword case of a statement without touching what it does. Clauses move onto their own lines, nested subqueries indent one level, and the joins line up so that you can see at a glance which tables a query actually touches. The parsed statement is identical before and after, so formatting is safe to run on anything you can read.
Formatting is usually the first step in understanding somebody else’s query. A four-hundred-character single line hides an accidental cross join; the same text with one clause per line makes the missing ON condition obvious. String literals and comments are copied through exactly as written, including any SQL-looking text inside them, because rewriting the contents of a literal would change the query’s meaning.