SQL Formatter

No upload · runs in your browser
Keywords
Indent
SQL in
0 characters
Formatted SQL

Runs entirely in your browser, nothing is uploaded.

How it works

SQL Formatter: Clause-Aware Indenting and Keyword Case

Paste a messy query for clause-aware indentation and consistent keyword casing. Strings and comments are copied through untouched, or minify to one line.

What this does
  • Clause-aware layout, SELECT, FROM, JOIN, WHERE and GROUP BY each open a new line
  • Sub-queries and CREATE TABLE column lists indent by nesting depth
  • CASE, WHEN, ELSE and END line up together, and BETWEEN … AND is never broken across lines
  • Keyword casing and indent width are both switchable: upper, lower or preserve, over two spaces, four spaces or a tab
  • Postgres dollar-quoting, MySQL backticks, T-SQL [brackets] and :named binds all survive as opaque atoms
  • Minify collapses each statement onto one line and reports the bytes saved
FAQ

It should not, and there is a check that proves it for each run. Strings, quoted identifiers, dollar-quoted bodies and comments are captured whole by the tokeniser and copied through byte for byte, so only whitespace and keyword casing ever change. The formatted text is then re-tokenised and compared against the original token stream. If the two differ anywhere, the tool hands your input straight back with a note saying the safety check failed, rather than returning a query it is not sure about.

Keep going