SQL formatter

Make SQL queries readable.

Dialect
Keywords
Indent

0 lines · 0 characters

0 lines · 0 characters

Results update as you type.

Runs in your browser. Nothing uploaded.

How to format SQL

  1. Paste one or more SQL statements into SQL.
  2. Pick the Dialect your database uses. Standard works for most everyday queries.
  3. Choose how Keywords are written and the Indent, then copy the formatted query.

The layout it produces

Each main clause (SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT) starts on its own line, and its contents are indented underneath. Selected columns get one line each, joins sit under FROM with their ON conditions, and several statements are separated by a blank line.

This style makes queries easy to scan and gives clean diffs: adding a column changes one line instead of rewriting a long one.

When a formatter helps most

  • Reading queries copied from logs or generated by an ORM, which usually arrive as one long line.
  • Reviewing a pull request with SQL migrations or reports.
  • Spotting mistakes like a join condition that ended up in the wrong place, which stands out once each clause has its own line.

The formatter runs in your browser, so queries that mention real table names or customer data aren’t sent anywhere.