SQL Formatter
Format a query for a dialect you choose, with highlighting. It does not connect to a database or run the query.
Text in quotes, names in backticks or double quotes, and comments stay exactly as written. The query is not run or checked against a database.
Your result
Paste a query and the tidy version appears here.
How to use it
- Paste the query or press Try a sample.
- Choose the dialect and how keywords are written.
- Copy the result or download it as a .sql file.
Examples
- A short queryselect name from people where city = 'Cairo' SELECT name FROM people WHERE city = 'Cairo'
- Two conditionswhere a = 1 and b = 2 WHERE a = 1 AND b = 2
- A keyword inside textwhere note = 'from here' WHERE note = 'from here'
Tool details and privacy
Paste a long one-line query and get a readable version: SELECT, FROM, WHERE, and JOIN each on a line, with columns and conditions indented.
A tidy query is easier to review and makes a missing condition or a misplaced JOIN easier to spot.
Options
- Keywords: UPPER, lower, or as typed.
- The dialect adds its own words, such as ILIKE and RETURNING for PostgreSQL and REGEXP for MySQL.
Limits
- Quoted text, names in backticks or double quotes, and comments stay exactly as written.
- Formatting does not check or run the query.
Privacy
What you type stays in your browser. Nothing is uploaded or saved on the server.
Questions
Can formatting change what the query does?
No. Only spacing, line breaks, and keyword case change.
Is LEFT JOIN kept on one line?
Yes, with its ON condition on the same line.
Is the query run?
No, and no database is contacted.
Is the text uploaded?
No.