SQL Formatter & Beautifier
Paste messy SQL — get clean, indented output with clause line-breaks and keyword casing.
The SQL Formatter beautifies messy or machine-generated SQL into clean, readable queries — each major clause on its own line, columns broken out, and keywords cased the way you prefer. It also minifies SQL to a single line. Ideal for queries copied from ORMs, application logs and query builders.
- ✓Clause line-breaks for SELECT, FROM, JOIN, WHERE, GROUP BY…
- ✓Uppercase, lowercase or preserve keyword casing
- ✓Minify SQL down to a single line
- ✓Dialect-agnostic and 100% private
What the SQL Formatter Does
The formatter tokenizes your SQL — correctly handling quoted strings, identifiers and comments — then reflows it: major clauses like SELECT, FROM, WHERE, JOIN, GROUP BY and ORDER BY each start on their own line, column lists break after commas, and parentheses are indented by nesting depth. Keyword casing is configurable and everything runs locally in your browser — it reflows structure rather than validating a specific database dialect.
How to Format SQL Online
- 1Paste your raw, minified or ORM-generated SQL into the input panel
- 2Choose UPPER, lower or Keep for keyword casing
- 3Click Format to reflow it, or Minify to collapse it to one line
- 4Copy or download the result
Example
Input (single line, from an ORM log):
select u.id, u.name, count(o.id) as orders from users u left join orders o on o.user_id = u.id where u.active = true and o.created_at > '2024-01-01' group by u.id, u.name having count(o.id) > 3 order by orders desc limit 10;Output (formatted, UPPER keywords):
SELECT
u.id,
u.name,
COUNT (o.id) AS orders
FROM users u
LEFT JOIN orders o ON o.user_id = u.id
WHERE u.active = true
AND o.created_at > '2024-01-01'
GROUP BY u.id, u.name
HAVING COUNT (o.id) > 3
ORDER BY orders DESC
LIMIT 10;Keyword Casing Options
| Mode | SELECT becomes | Best for |
|---|---|---|
| UPPER | SELECT | Traditional SQL style guides, most style guides and textbooks |
| lower | select | Modern codebases that prefer lowercase SQL |
| Keep | (unchanged) | Preserving the exact casing already in the query |
Features
Clause line-breaks
SELECT, FROM, JOIN, WHERE, GROUP BY and ORDER BY each start a new line.
Configurable keyword casing
UPPER, lower or Keep — applied only to recognized SQL keywords.
Minify to one line
Collapse a query to a single line with comments stripped, for logs or embedding in code.
Nested subqueries
Parentheses are indented by nesting depth, so subqueries stay readable.
Preserves literals exactly
Quoted strings, quoted identifiers and comments are never altered.
100% private
Formatting runs entirely in your browser — safe for production queries and schemas.
Who Uses This
- ▸Backend engineers — clean up single-line queries logged by an ORM (Prisma, Sequelize, ActiveRecord, Hibernate) before debugging them.
- ▸Code reviewers — reformat a teammate's query to the team's keyword-casing convention before approving a PR.
- ▸Data analysts — tidy up ad-hoc queries pulled from a BI tool or query builder before sharing them.
- ▸Students and educators — use consistent indentation to make JOIN and subquery structure easier to teach and read.