SQL copied out of application logs or an ORM usually arrives as one enormous line. Formatting it — putting each clause on its own line and indenting the joins — is the fastest way to understand what a query does and to spot the bug you are hunting.
What good formatting shows you
Once SELECT, FROM, each JOIN and the WHERE clause sit on their own lines, the shape of the query becomes obvious: how many tables it touches, which joins might multiply rows, and where a missing condition is causing a runaway result. A tidy layout turns a five-minute squint into a five-second read.
How to format a query
- Open the SQL formatter and paste your query.
- It re-indents the query with clauses and joins on their own lines.
- Copy the clean version back into your editor. Your query never leaves your browser, which matters if it contains table or column names you would rather not share.
Formatting is not optimising
A formatter changes only whitespace and capitalisation — it will not make a slow query fast. But it makes the reasons a query is slow far easier to see, such as a join with no condition or a filter on a column that is not indexed.