Loading tool…
About the SQL Formatter
Paste a dense or minified SQL query to get it reformatted with each major clause (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY) on its own line and keywords capitalized, so it’s easier to read and review.
How to use the SQL Formatter
- Paste your SQL query.
- Click Format.
- Major clauses are placed on new lines with consistent indentation.
- Copy the formatted result.
Step-by-step walkthrough with examples and the errors people hit: How to Format SQL Queries for Readability.
Example
Input
select id, name from users where active = true and role = 'admin' order by name→
SELECT id, name FROM users WHERE active = true AND role = 'admin' ORDER BY name
Common errors and how to fix them
An identifier was uppercased
A column or alias spelled like a keyword, such as a column named "in", is treated as one. Quote such identifiers in the source.
Commas inside a function split lines
They should not; commas are only broken at clause level. If you see it, check for an unbalanced parenthesis earlier in the query.
More problems and fixes in the tutorial
FAQ
Which SQL dialect does this support?
It uses a dialect-agnostic keyword-based formatter that handles standard clauses common across MySQL, PostgreSQL, and SQLite. It does not validate query correctness or dialect-specific syntax.
Does this validate my SQL?
No — it reformats the text based on recognized keywords; it doesn’t parse or execute the query, so a malformed query will still be reformatted rather than flagged.
Is my query uploaded anywhere?
No, formatting happens entirely in your browser. SQL queries can contain sensitive table/column names, so nothing is sent over the network.