Quick Answer
A SQL formatter takes a dense, single-line query and lays it out so each clause (SELECT, FROM, WHERE, JOIN…) starts on its own line, keywords are uppercased, and parentheses indent properly. Readability without changing what the query does.
What This Tool Does
The formatter tokenizes your SQL — respecting string literals so it never touches their contents — then rebuilds it with your chosen keyword casing, major clauses on fresh lines, commas grouped, and parentheses indented. A trailing semicolon ends cleanly. Advanced options add identifier casing, comment removal and a compact mode.
Key Features
- Keyword casing — upper, lower, capitalize or unchanged (e.g.
selectbecomesSELECT). - Identifier casing — optionally normalize column and table names separately.
- Clause-per-line —
FROM,WHERE,GROUP BY,ORDER BYstart their own lines. - Indentation options — 1–8 spaces or tabs.
- Compact mode — fewer line breaks when you want tighter output.
- Comment removal — strips
-- lineand/* block */comments on request. - Paren-aware — subqueries indent by depth.
- String-safe — quoted literals are preserved exactly.
- Upload file or load from URL — format existing .sql files directly.
How to Use the SQL Formatter
- Paste your SQL into the input box, or use Upload File / Load from URL.
- Pick a keyword case and indentation style.
- Open Show advanced options for identifier casing, comment removal or compact mode.
- Read the formatted query on the right — updates live.
- Copy or download the result.
Use Cases
- Reviewing a long query pulled from logs or an ORM.
- Standardizing query style across a team’s shared snippets.
- Reading nested subqueries and CTEs without squinting.
Tips
- String literals containing words like "from" are safe — the formatter tracks quotes.
- For CTEs, check the indentation of the
WITHblock once; deep nesting can still be dense.
Privacy
Formatting happens locally — your queries never leave the browser.
Conclusion
SQL is easier to trust when you can read it. Format any query here in seconds — free and private.