SQL Formatter
Format SQL into a consistent, reviewable shape with keyword casing options.
Nothing formatted yet
Paste a query and press Format. String literals and comments are preserved exactly, so formatting cannot change what it means.
Runs entirely in your browser. Your data isn't uploaded — this page makes no network request with anything you type, which you can verify in your browser's network tab. How this works.
What is the SQL Formatter?
A query that arrives as one 400-character line cannot be reviewed, and a query formatted differently by every author produces diffs nobody can read. Consistent formatting is what makes SQL reviewable in a pull request.
This formatter breaks clauses onto their own lines, indents nested expressions and subqueries, aligns join conditions, and normalises keyword casing — while leaving string literals, comments and identifier quoting exactly as they were.
How to use it
- Paste your SQL, or upload a .sql file.
- Choose keyword casing (upper, lower or unchanged) and indentation width.
- Press Format (or Ctrl/Cmd + Enter).
- Copy the formatted query, or download it.
Example
A one-line query, reflowed for review.
select u.id,u.email from users u join orders o on o.user_id=u.id where o.total>100 order by u.id
SELECT u.id,
u.email
FROM users u
JOIN orders o
ON o.user_id = u.id
WHERE o.total > 100
ORDER BY u.id
Features
- Clause-per-line layout with indented subqueries and CTEs
- Keyword casing normalisation without touching identifiers
- String literals and comments preserved verbatim
- Handles multiple statements in one input
- Configurable indentation width and comma placement