SQL Formatter

Format and beautify SQL queries in your browser. Supports MySQL and PostgreSQL dialects.

Runs entirely in your browser. Nothing is sent to our servers.

About this tool

This formatter rewrites SQL queries for readability — uppercase keywords, one clause per line, consistent indentation. It works on MySQL, PostgreSQL, SQLite, and most SQL dialects. The formatter is dialect-agnostic for the common subset (SELECT, JOIN, WHERE, GROUP BY, ORDER BY, INSERT, UPDATE, DELETE, CTEs).

What's preserved

  • String literals (single or double quoted) — characters inside quotes aren't touched.
  • Comments — both -- line and /* block */.
  • Identifier quoting — backticks, double quotes, and square brackets pass through.
  • Numeric literals.

What gets changed

  • Keyword case is normalized.
  • Whitespace is collapsed and re-inserted with consistent indentation.
  • Major clauses (SELECT, FROM, WHERE, etc.) get their own line.
  • Comma-separated lists are wrapped one item per line.

Frequently asked questions

Does this run my SQL?
No. The tool only reformats text. It doesn't connect to any database, parse for correctness beyond what's needed for formatting, or execute anything.
Will it handle vendor-specific syntax?
It treats most vendor extensions (window functions, MySQL hints, Postgres array operators, etc.) as opaque tokens — the formatting around them works, but very exotic syntax may not lay out beautifully. Output is always syntactically equivalent to input.
Why doesn't my CTE format nicely?
Long deeply-nested CTEs are a known weak spot of simple formatters. For complex queries, run the formatter and then hand-tweak — the goal is to save 90% of the keystrokes, not to be perfect.
Is my SQL sent anywhere?
No. All formatting happens in your browser.

Last updated: May 17, 2026