SQL formatter

How to use the SQL formatter

  1. Paste SQL (any dialect — MySQL, PostgreSQL, SQL Server, SQLite, Oracle).
  2. The formatted output breaks clauses onto new lines with consistent indent.
  3. Pick a dialect for dialect-specific syntax awareness (JSON operators, window functions, CTEs).
  4. Toggle uppercase keywords and copy the formatted query.

When to use it

Format SQL before committing to a repo, before sharing a query in a Slack message, or before running it against production (easier to spot typos and missed joins). In-editor formatters (VS Code SQL Formatter, DBeaver auto-format) are faster for daily work; this tool is useful when you're in a browser tab with a web SQL console.

Frequently asked questions

Does it validate the SQL?
It parses the query well enough to format it — syntax errors will usually break formatting. For validation, run the query against an actual database or use a linter like sqlfluff.
Can it format stored procedures?
Yes, including BEGIN/END blocks, IF/ELSE, and cursor declarations. Nested subqueries and CTEs indent correctly.
Why are my table aliases changing case?
Only keywords and reserved words are uppercased — identifiers (table names, aliases) preserve their original case. If your aliases are getting transformed, check whether you've accidentally matched a reserved word.
How do I format a single-line query?
Paste it and the formatter expands it onto multiple lines automatically. Toggle 'compact' mode if you want the query flattened back to one line after other transforms.

Related tools

Last updated: 2026-04-22