chaitanya.dev / Tools / SQL Formatter

SQL Formatter

Paste messy SQL, get clean SQL. Preserves string literals and comments, uppercases keywords, puts each major clause on its own line.

Clean up SQL before you paste it into a review

Unformatted SQL in a PR is a signal that nobody read it carefully. This tool normalises whitespace, uppercases keywords, puts SELECT / FROM / WHERE / each join on their own lines, and indents AND / OR / ON. String literals and comments pass through untouched.

Scope + caveats

  • Vendor-agnostic. The keyword list covers ANSI SQL plus the common extras (RETURNING, ILIKE, PARTITION BY). Vendor-specific syntax (T-SQL WITH (NOLOCK), Postgres LATERAL, Snowflake QUALIFY, BigQuery UNNEST) passes through unchanged.
  • Not a parser. It’s a regex-driven formatter — if your SQL is syntactically broken, it’ll still “format” it. Trust your database’s EXPLAIN for correctness, not this tool.
  • String literals and comments are preserved byte-for-byte. Single- and double-quoted strings, -- line comments, and /* … */ block comments are stashed before formatting and restored after.
  • Runs entirely in your browser. Paste queries containing sensitive table names or inline data without worrying about where they end up — they don’t leave the tab.