SQL formatter
Format SQL queries with each clause on its own line, consistent indentation and uppercase keywords.
Related tools
SQL formatter
Paste any SQL query and get it back readable: SELECT, FROM, WHERE, JOIN, GROUP BY, HAVING, ORDER BY and the other major clauses each start their own line, AND and OR conditions continue indented beneath them, and every column in the select list can sit on its own line. Pick two spaces, four spaces or tabs for indentation, and choose whether keywords are uppercased — the classic SELECT/FROM/WHERE capitalization that makes structure visible at a glance.
The formatter is built on a real tokenizer, not a pile of find-and-replace rules. String literals such as 'it''s', quoted identifiers in every dialect style ("column", `column`, [column]) and both comment styles (-- line and /* block */) pass through byte for byte, so a keyword inside a string is never touched and a quote inside a comment never confuses it. Only whitespace and keyword case ever change — the query you get out means exactly what the query you pasted in meant.
Multiple statements separated by semicolons are recognized and formatted as separate blocks, which makes the tool practical for migration files and seed scripts, not just single queries. It is honest about its limits: deeply nested subqueries stay on their clause's line rather than being re-indented, which keeps the result predictable for the queries you actually debug day to day.
Everything runs locally in your browser — queries that contain table names, credentials or production data never leave your machine. Copy the result or download it as a .txt file when you are done.