UtilityBase logoUtilityBase

Developer Tools

SQL Formatter

Format messy SQL into readable, consistently indented queries — locally.

Updated July 9, 2026

How to use the sql formatter

  1. 1Paste your SQL — it stays in your browser.
  2. 2Pick the dialect that matches your database.
  3. 3Set keyword case and indent width.
  4. 4Copy the formatted query.

Common uses

  • Cleaning up a query before a code review or pull request
  • Making a logged one-line query readable for debugging
  • Standardizing keyword casing across a team's SQL files
  • Formatting ORM-generated SQL to understand what it actually does

Frequently asked questions

Why does the dialect setting matter?

Because real SQL diverges from the standard exactly where queries get interesting: PostgreSQL's :: casts and jsonb operators, SQL Server's [bracketed identifiers] and TOP, MySQL/BigQuery backticks, SQLite's pragmas. Under the wrong dialect these tokens can misparse and format strangely. Pick the database you actually run; 'Standard SQL' is the fallback for textbook queries.

Will formatting ever change what my query does?

No — the formatter re-arranges whitespace, line breaks, and keyword casing only; identifiers, literals, operators, and clause order pass through untouched. Keyword casing doesn't affect execution in any mainstream database (identifier casing can, and those aren't touched). The formatted query is byte-for-byte semantically identical, which is what makes format-before-code-review safe.

Is it safe to paste production queries here?

Yes, and that's the point of this tool existing: the formatting engine runs locally in your browser, so queries containing real schema — table names, column names, the shape of your business logic — never leave your machine. Verify it yourself: load the page, disconnect from the internet, and formatting still works.

Uppercase or lowercase keywords?

Uppercase is the traditional convention and still dominates documentation — keywords pop against lowercase identifiers, useful without syntax highlighting. Lowercase has grown fashionable in modern codebases where editors highlight anyway. Databases don't care; teams should just pick one, and a formatter is precisely how you enforce it cheaply.

About this tool

The SQL formatter turns one-line query soup into properly indented, readable SQL using the open-source sql-formatter engine — running entirely in your browser, which matters more for SQL than almost any other text: production queries expose table names, columns, and business logic that don't belong on a random cloud formatter. Six dialects (standard, PostgreSQL, MySQL, SQLite, SQL Server, BigQuery) parse their own syntax correctly — casts, brackets, backticks — with uppercase/lowercase keyword and indent options. Formatting is whitespace-only: your logic is never rewritten. Output formats live as you type, with one-click copy.

Like most tools on UtilityBase, the sql formatter runs entirely in your browser — nothing you enter is uploaded or stored on a server. It's free to use with no account required. Browse more developer tools here.

Was this tool helpful?

Related tools