SQL Formatter
Paste a SQL query and the formatter lays it out with each clause on its own line, one column per line and indented conditions and sub-queries.
- Paste your SQL query
- Choose indent and keyword case
- Copy the formatted or minified query
Your files never leave your device
How to format a query
Paste a SQL query, choose the indent size and whether keywords are written in upper case, and press Format. Each major clause starts on a new line, every item of a select list gets its own line and conditions are indented, so even a long query becomes easy to read. The Minify button does the opposite and puts the whole query on one line.
- Major clauses such as SELECT, FROM, WHERE and ORDER BY start on a new line.
- Select lists and group lists get one item per line, and AND or OR conditions are indented.
- Strings, quoted names and comments are kept exactly as written.
A worked example
Take the one-line query select id, name from users where age > 18 and active = 1 order by name. After formatting with upper-case keywords, SELECT stands on its own line with id and name on two lines below it, FROM users has a line, WHERE age > 18 has a line with AND active = 1 indented beneath it, and ORDER BY name closes the query. Nothing changed except whitespace and the case of the keywords.
Limits and good practice
The formatter only lays out the text. It does not run your query or check whether table and column names exist, so a formatted query can still contain an error. Use minify for a query you want to embed in code, remembering that comments are removed. Agree on an indent size and keyword case with your team so that every query in a project looks the same.
Frequently asked questions
Which SQL dialects work?
Standard SQL and common dialects such as MySQL, PostgreSQL, SQLite and SQL Server work for everyday queries. Very specific syntax may be laid out in a simpler way.
Does it change my query?
Only whitespace, line breaks and keyword case change. Names and values stay the same, so the query does exactly what it did before.
Does minify remove comments?
Yes. Comments are removed so the query fits on one line safely.
Can it format several statements?
Yes. Statements separated by semicolons are formatted one after another.
Does it check if the query is correct?
No. It formats the text but does not run or validate the query.
Is my SQL uploaded?
No. The formatting happens on your device, and your queries are not sent anywhere.