Skip to content

SQL Formatter

Format SQL queries with clauses on their own lines, one column per line and indented subqueries.

Runs in your browser — nothing you enter is sent to a server.

How the SQL Formatter works

Paste a query and it's reformatted as you type: each clause (SELECT, FROM, WHERE, JOIN, GROUP BY…) starts a new line, selected columns go one per line, AND and OR conditions line up, and subqueries are indented. Choose the keyword case and indent size.

The formatter works on tokens, so strings, quoted names and comments are never changed. It follows common SQL used by PostgreSQL, MySQL, SQLite and SQL Server; unusual dialect syntax is kept as written.

Formula

clause → new line · column → new line, indented · AND/OR → new line, indented

BETWEEN … AND … stays on one line.

Examples

A one-line query

SELECT
  id,
  name
FROM users
WHERE active = 1
  AND age > 18
ORDER BY
  name

A subquery

SELECT
  COUNT(*)
FROM t
WHERE id IN (
  SELECT
    id
  FROM s
)

Frequently asked questions

Does formatting change what the query does?

No — only whitespace and keyword case change. Strings and names are untouched.

Uppercase or lowercase keywords?

SQL doesn't care; uppercase keywords are a common convention that makes them stand out from names. Pick whatever your team uses.

Can it format several statements?

Yes — each statement ending in a semicolon is formatted separately, with a blank line between.

JSON Formatter

Format, validate and minify JSON, with the exact line and column of any error.

Developer Tools

Text Difference Checker

Compare two texts and highlight what was added, removed or changed, line by line or word by word.

Text Tools

Case Converter

Change text to UPPERCASE, lowercase, Title Case or Sentence case, or to camelCase, snake_case and kebab-case for code.

Text Tools