How to use the SQL Formatter
- 1. Paste your SQLAdd one query or several, separated by semicolons.
- 2. Set your styleChoose keyword case and 2 or 4 space indents.
- 3. Copy the resultCopy the formatted query or download it as a .sql file.
What good SQL formatting looks like
A readable query puts each main clause on its own line, so you can scan it the way you read a report. For example, this:
select id, name from users where city = 'Noida' and active = 1 order by namebecomes this:
SELECT
id,
name
FROM
users
WHERE
city = 'Noida'
AND active = 1
ORDER BY
nameSubqueries are indented one step further, joins sit inside the FROM block, and CASE statements get a line for each WHEN. Lists inside brackets, such as function arguments and IN lists, stay on one line to keep things short.
What this tool will not change
Only spacing and keyword case change. Text in quotes, quoted column names and comments stay exactly as written, so 'select from' inside a string is left alone. Table and column names keep the case you typed.
The tool does not connect to any database and does not run your query. That also means it cannot tell you if a query is wrong, only make it easier to spot the problem yourself. An unclosed quote is the one error it does catch, with the line and column.
MySQL users who write \' inside strings should tick the backslash option. Exported the results as JSON? Move them to a spreadsheet with the JSON to CSV converter, or tidy them with the JSON formatter.
Frequently asked questions
Which SQL dialects does it support?
It works on common SQL used in MySQL, PostgreSQL, SQL Server, SQLite and Oracle, because it focuses on layout, not on one dialect's rules.
Is my query sent to a server?
No. It is formatted in your browser and never runs on any database.
Will it change my data or logic?
No. Only spaces, line breaks and keyword case change. Strings and comments stay the same.
Is this tool free?
Yes, it is free. We ask for your name and WhatsApp number once when you see your result, and other Uncodemy tools then open without the form.