How to format (beautify) SQL
Short answer
Paste the query into a SQL formatter and it re-indents clauses, aligns keywords, and puts each column or condition on its own line so the logic is easy to read. It does not change what the query does.
What formatting does
A SQL formatter parses the query and re-prints it with consistent indentation and line breaks. It only changes whitespace and casing conventions, never the result. Readable SQL is easier to review, debug, and diff in version control.
select id,name from users where active=1 and role='admin' order by name;
SELECT id, name
FROM users
WHERE active = 1
AND role = 'admin'
ORDER BY name;Format a query
- Paste the SQLDrop in a minified or hand-written query.
- Read the formatted outputClauses align and each column or condition gets its own line.
- Copy it backPaste the clean version into your code, migration, or ticket.
Conventions that keep SQL readable
- Uppercase keywords (SELECT, FROM, WHERE) so they stand out
- One column or condition per line for easy diffs
- Indent subqueries and JOIN conditions
- Consistent aliasing so joins are easy to follow