SQL formatter example: a compressed query

What clause breaks change for a reviewer, and what this formatter does not claim about the database.

Open SQL Formatter to run this case yourself.

Compressed

select o.id, c.name, o.total from orders o inner join customers c on c.id = o.customer_id where o.status = 'paid' and o.total > 100 order by o.total desc

Formatted by CompareStack

SELECT o.id,
c.name,
o.total
FROM orders o
INNER
JOIN customers c ON c.id = o.customer_id
WHERE o.status = 'paid' AND o.total > 100
ORDER BY o.total desc

The problem

The query is valid enough to read in one sitting, and that is the problem. SELECT, JOIN, WHERE, and ORDER BY sit on one line. A reviewer scanning a ticket is likely to miss which table is joined, which filter limits rows, and which column is sorted.

What the formatter actually emits

CompareStack collapses whitespace, uppercases a fixed keyword list, and inserts a line break before keywords such as SELECT, FROM, WHERE, JOIN, INNER, and ORDER. Commas in the select list also start a new line. The block above is the real output of that pass, not a hand-edited ideal.

SELECT is the column list. FROM names the driving table. INNER JOIN adds customers, and ON states the key. WHERE keeps paid orders over 100. ORDER BY sorts by total. Breaking those clauses apart is a readability change for a human. It is not a rewrite of the query’s meaning, and it is not a performance change. The database does not run faster because the keywords moved to their own lines.

Limits visible in this output

INNER and JOIN are both on the newline-keyword list, so they land on separate lines. The select columns are not indented under SELECT. desc stays lowercase because it is not in the keyword list. There is no special layout for WITH / CTE clauses, and there is no check that the SQL is valid PostgreSQL, MySQL, or T-SQL. Read the result before you run it or paste it into a pull request.

When this tool may not be the right choice

  • You need a dialect parser, a linter, or an EXPLAIN plan. Formatting will not tell you that a join key is missing or that a filter does not use an index.
  • You need stable formatting for a repository. A team style enforced by a SQL formatter in CI is a better source of truth than a one-off browser pass.
  • You want the formatter to prove the query is safe to run. It only changes whitespace and keyword case for the words it recognizes.

Processing and privacy

Paste tools also run on the server. The text is sent in the form POST, with a limit of 100,000 characters per field. It is not written into a document library or a user account. Server logs can still record technical request metadata such as IP address and URL. Do not paste secrets, credentials, or personal data you are not allowed to send to a web service.

The Privacy Policy and how processing works are the full description.

Open SQL Formatter

Related examples

Related guides