SQL Formatter

Formats a SQL query for readability. Each clause starts a new line, the select list is broken one column per line, AND and OR are indented under their clause, and reserved keywords are uppercased while your table and column names are left exactly as written. String literals and comments are never altered. Runs entirely in your browser — nothing is sent to a server.

Ad placeholder: Resp_Horizantal_1 (horizontal)
Ad placeholder: Resp_Square_1 (square)

Formats a SQL query for readability. Each clause starts a new line, the select list is broken one column per line, AND and OR are indented under their clause, and reserved keywords are uppercased while your table and column names are left exactly as written. String literals and comments are never altered. Runs entirely in your browser — nothing is sent to a server.

Use cases

  • Making a long one-line query from an ORM log readable
  • Tidying a query before pasting it into a pull request

Examples

One-line query

select id, name from users where active = 1 and age > 18 order by name;
SELECT
  id,
  name
FROM users
WHERE active = 1
  AND age > 18
ORDER BY name;

FAQ

Is my query sent to a server?

No — this tool runs entirely in your browser.

Why is the inside of my subquery still on one line?

Line breaks are only applied outside parentheses. Deciding how to break function calls and subqueries needs a full SQL parser, and guessing wrong mangles the query, so parenthesised groups are left inline.

Which SQL dialect is supported?

Formatting is lexical rather than dialect-specific, so standard SQL plus MySQL backticks and SQL Server bracket identifiers all work.