SQL Formatter: Format SQL Queries
Pretty-print SELECT, JOIN, CTE, and UNION queries in this browser. The tokenizer keeps strings, comments, and quoted identifiers intact, then indents clauses. SQL is never executed or uploaded.
Load file
Ctrl+Enter or Cmd+Enter formats. Client-only FileReader. Max 1.5 MB.
Formatted SQL
Output stays in this page until you copy or export it.
Paste SQL and press Format. Nothing leaves this browser.
What this formatter does
It is a pretty-printer for the shared SELECT / DML core of PostgreSQL, MySQL, and SQLite. It does not connect to a database, rewrite plans, or validate every dialect rule.
- Tokenizes line comments, block comments, quoted strings, quoted identifiers, numbers, and placeholders so commas inside
'O''Brien'are not clause breaks. - Puts SELECT, FROM, WHERE, JOIN, GROUP BY, HAVING, ORDER BY, LIMIT, WITH / CTE, UNION, INSERT, UPDATE, and CASE on structured lines with nested parentheses indented.
- Uppercases known keywords when asked; leaves string literals and quoted identifiers unchanged.
- Reports unterminated strings or comments, unbalanced parentheses, empty input, and oversize files. Semantically invalid SQL may still format if the tokens are well-formed.
Common subset: single-quoted strings with doubled quotes; double-quoted, backtick, and bracket identifiers; PostgreSQL dollar-quotes and E-strings. MySQL # comments and -- requiring a space apply only when Dialect notes is MySQL.