SQL Formatter & Beautifier
Strings, quoted identifiers and numbers are never changed. Formatting is cosmetic and does not validate the query.
What does a SQL formatter do?
A SQL formatter rearranges a query into a consistent, readable layout without changing what it does. Major clauses such as SELECT, FROM, WHERE and GROUP BY start on their own lines, columns are listed one per line, conditions joined by AND or OR are indented, and subqueries are indented inside their parentheses. It can also minify a query into a single line.
How to use it
- Paste your SQL into the box.
- Pick the dialect (it affects how quoted names such as `name`, [name] or $$text$$ are read) and the indentation.
- Press Format to beautify or Minify to compress, then copy the result.
Example
This query:
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=1 and u.age between 18 and 30 group by u.id,u.name order by orders desc limit 10;
becomes:
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 = 1
AND u.age BETWEEN 18 AND 30
GROUP BY u.id, u.name
ORDER BY orders DESC
LIMIT 10;
Frequently asked questions
Does formatting change my query?
No. Only whitespace and the case of keywords change. Strings, quoted identifiers and numbers are left exactly as written, so the query behaves the same.
Which dialects are supported?
Standard SQL, MySQL and MariaDB (backtick names, # comments), PostgreSQL (dollar-quoted strings and :: casts) and SQL Server (square-bracket names). Other dialects usually work for everyday queries.
Does it check my SQL for errors?
No. It formats what you give it and does not validate the syntax or run the query.
Is my SQL uploaded?
No. Formatting runs in your browser, so queries with table names or data never leave your device.
Why are some words not uppercased?
Only common keywords and functions are changed, and words used as names, such as a column called date, are left alone to avoid altering identifiers.
Related tools
JSON Formatter · XML to JSON · Case Converter · Text Compare
Results are estimates for information only and are not financial, tax or legal advice.