Reading a one-line report query by laying it out clause by clause
Here is a query as it often arrives, copied from a log or an ORM: select c.name, count(o.id) as orders from customers c left join orders o on o.customer_id = c.id where c.country = 'NO' and o.total > 100 group by c.name order by orders desc. It is one line of 174 characters. It is valid SQL, but finding the join condition or the filter means reading it from the start every time.
The formatter puts each clause on its own line, with what belongs to the clause indented below it. SELECT is followed by two lines, c.name and COUNT(o.id) AS orders, one column each. FROM is followed by customers c, and on the next line LEFT JOIN orders o ON o.customer_id = c.id. The join keeps its ON condition on the same line, because a join without its condition is hard to read. WHERE is followed by c.country = 'NO', and then AND o.total > 100 on a line of its own. GROUP BY c.name and ORDER BY orders DESC finish the query. The result is 13 short lines.
Now the query is easy to check. You can see there is one join and what it joins on. You can see both filters, and you might notice something worth asking about. The filter o.total > 100 is in the WHERE clause, but o comes from a LEFT JOIN. A customer with no orders has a NULL total, the filter drops them, and the LEFT JOIN acts like an inner join. On one line that is easy to miss. In the formatted query, the LEFT JOIN line and the AND line sit close together.
Notice what did not change. The string 'NO' is still 'NO', in capitals and in quotes. The keywords were turned into capitals because the Keywords option was set to SELECT. Set it to select and they all come out in lower case, or pick As typed and they stay as you wrote them. Common function names such as COUNT, SUM and COALESCE follow the same setting. The alias orders and the table names are not keywords, so they are never changed.
The formatter has limits. It does not parse SQL the way your database does, so it cannot tell you about a missing comma, a wrong column name or a keyword your dialect lacks. It lays out what is there. Very unusual syntax, such as a vendor-specific clause it does not know, still comes out readable but may sit on the line of the clause before it. And it does not change the query in any way: it never reorders clauses, adds aliases or rewrites joins. If the formatted query looks wrong, the original was wrong in the same way.