SQL Formatter - Readable Queries, One Clause Per Line
A one-line query with five joins is technically valid and practically unreadable. Paste it below and get the same query back in the layout you would write by hand on a good day.
How to use the SQL Formatter
- Paste your SQL query into the top box.
- Leave "Uppercase keywords" ticked for the classic look, or untick it to keep your original keyword case.
- Click Format SQL.
- Copy the formatted query or download it as a .sql file.
How it works
The formatter tokenises your query first, so quoted strings, double-quoted and back-quoted identifiers are carried through untouched - a literal like 'select me' never gets uppercased or split. It then walks the token stream recognising multi-word clauses such as GROUP BY, ORDER BY and LEFT OUTER JOIN, starts each major clause on a fresh line, and puts AND and OR conditions on their own indented lines. Spacing around operators and commas is normalised to the conventional single space.
Worked example
The one-liner select id, name from users where age > 18 and city = 'New York' order by name limit 10 becomes six clean lines - SELECT, FROM, WHERE, an indented AND, ORDER BY and LIMIT - ready to paste into a review or a ticket.
Frequently Asked Questions
Is this SQL formatter free?
Yes - completely free, with no sign-up, no size limit and no daily cap.
Which SQL dialects does it support?
The formatter works on clause structure, not dialect rules, so standard SQL from MySQL, PostgreSQL, SQL Server, SQLite and others all format the same way. It beautifies layout only - it does not validate that your query would run.
Does it re-indent subqueries?
No - parenthesised subqueries stay on the line where they appear. Deep subquery indentation is where formatters most often guess wrong, so this tool sticks to clause-level layout and says so honestly.
Are my string literals safe?
Yes. Single-quoted strings (including doubled-quote escapes), double-quoted and back-quoted identifiers pass through byte-for-byte; only keywords outside them are uppercased.
Is my SQL uploaded to a server?
No. Formatting happens 100% in your browser. Your queries - schema names and all - never leave your device.
Related Developer Tools
JSON Formatter
Validate, pretty-print and minify JSON, with the exact position of any error.
Regex Tester
Test regular expressions live - matches highlighted, capture groups listed, count shown.
YAML ⇄ JSON Converter
Convert the common YAML subset (maps, lists, scalars) to JSON and JSON back to YAML - honestly scoped.