Why format SQL?
Queries copied from logs, ORMs or old code often arrive as one long line. Formatting puts each clause (SELECT, FROM, JOIN, WHERE, GROUP BY) on its own line with consistent indentation, which makes bugs easier to spot and code reviews faster.
Before and after
select u.name,count(o.id) from users u left join orders o on o.user_id=u.id where u.active=1 group by u.name
SELECT
u.name,
COUNT(o.id)
FROM
users u
LEFT JOIN orders o ON o.user_id = u.id
WHERE
u.active = 1
GROUP BY
u.name
Choosing the dialect
Pick your database (MySQL, PostgreSQL, SQL Server, SQLite or Oracle) so the formatter understands its special syntax, such as backtick identifiers in MySQL or :: casts in PostgreSQL.
Upper or lower case keywords?
SQL doesn't care, but teams do. Upper case keywords (SELECT) make the structure stand out from table and column names and are the most common style. Pick one and use it everywhere.
Does formatting change what the query does?
No. Only spaces, line breaks and keyword case change. Strings and identifiers are left exactly as they are. Your SQL never leaves your browser, so it's safe to format queries that contain table names or data.