SQL Formatter
Break long queries onto readable clause lines
Everything runs in your browser. Your data never leaves your device.
Related tools
How to use
A single-line query of any length is unreviewable. Formatting puts each major clause on its own line and indents what belongs to it, which turns a wall of text into something you can scan for a missing join condition.
Paste your query
Queries copied from application logs or ORM output are usually a single long line. Paste as-is; the formatter does not need it pre-cleaned.
Set the indentation
Two spaces, four spaces or tabs, applied to column lists and to AND and OR conditions within a WHERE clause.
Review the clause structure
With SELECT, FROM, JOIN, WHERE and GROUP BY each on their own line, a missing join condition or an accidental cross join becomes visible immediately.
Examples
A logged query
A 300-character single-line query with three joins and a HAVING clause formats into roughly fifteen lines, with each join and each condition on its own line and column lists indented beneath SELECT.
Literals are protected
In WHERE title = 'order by date', the quoted text stays intact — it is extracted before keyword matching, so ORDER BY inside a string never triggers a line break.
About this tool
Format SQL by breaking before each major clause and indenting column lists and conditions. String literals are protected before any keyword matching, so a value containing words like 'order by' is never mistaken for a clause. Works with standard SQL across PostgreSQL, MySQL, SQLite and SQL Server.