Skip to main content

SQL Formatter

Paste a one-line SQL query and get a properly formatted version: keywords uppercased, each clause on its own line, subqueries indented. Runs entirely in your browser — production queries never leave your machine.

How it works

The formatter tokenizes your SQL — separating strings, quoted identifiers, comments, and numbers from code — then re-writes it with structural rules: major clauses (SELECT, FROM, WHERE, GROUP BY, ORDER BY, joins, UNION) start new lines, AND/OR break onto their own lines, and parentheses increase indentation depth. Strings and comments pass through untouched.

When it helps most

  • Debugging: a 400-character one-liner from an ORM log becomes a structure you can actually read
  • Code review: normalized formatting makes diffs show real changes, not whitespace noise
  • Docs and tickets: pasting readable SQL into issues gets faster answers than wall-of-text queries

It is deliberately a formatter, not a validator — dialect specifics (Postgres :: casts, MySQL backticks) are preserved as-is. For the data coming out of those queries, the JSON to CSV converter is the next stop.