HTTPfy

SQL Formatter

Format SQL queries so they read cleanly.

SQL Formatter Ready

About SQL Formatter

SQL Formatter: Make Long Queries Readable

Paste a SQL query and the formatter puts each clause on its own line, indents subqueries and column lists, and converts keywords such as select, from and where to uppercase. Table names, column names and string values stay as you wrote them.

Before and After

A query copied from an ORM log or a one-line script:

select u.id, u.email, count(o.id) as orders from users u left join orders o on o.user_id = u.id where u.created_at > '2025-01-01' group by u.id, u.email order by orders desc

comes back with SELECT, FROM, LEFT JOIN, WHERE, GROUP BY and ORDER BY each starting a line, and the column list indented under SELECT.

Why Format SQL

  • Reviews: one clause per line makes diffs smaller and shows which condition changed.
  • Debugging: a misplaced JOIN condition or a missing WHERE is easier to spot when the query has structure.
  • Consistency: uppercase keywords and a fixed layout make queries from different people look the same.

Limits

  • The formatter only changes whitespace and keyword case. It doesn't check syntax or run the query, so broken SQL comes back formatted but still broken.
  • It works with common syntax from MySQL, PostgreSQL, SQLite and SQL Server. Vendor-specific procedural code, such as long PL/pgSQL or T-SQL procedures, may format unevenly.
  • Strip passwords, customer data and other secrets from queries before pasting them into any online tool.