SQL Formatter

Beautify and minify SQL with keyword uppercasing/lowercasing and clause-per-line formatting — runs entirely in your browser.

Runs locally
Keywords:
Indent:
Input SQL
Output

What is a SQL formatter?

SQL (Structured Query Language) is the language used to query and manipulate relational databases. Raw SQL — especially from ORM query logs, concatenated strings, or production traces — is often hard to read: long lines, inconsistent keyword casing, no indentation. A SQL formatter rewrites a query by splitting on major clauses (SELECT, FROM, WHERE, JOIN, etc.), uppercasing keywords, and adding consistent indentation, making it easy to audit the query logic and spot issues.

How to use this tool

  1. 1 Paste your SQL into the Input panel or hit the sample button to load an example query.
  2. 2 Choose Beautify for formatted output or Minify to produce the most compact form.
  3. 3 Select keyword casing (UPPERCASE, lowercase, or keep as-is) and indentation width.
  4. 4 Copy the output with the copy button.

Frequently asked questions

Which SQL dialects are supported?

The formatter handles standard SQL keywords (SELECT, FROM, WHERE, JOIN, GROUP BY, etc.) and is dialect-agnostic for formatting purposes. Dialect-specific syntax (e.g. PostgreSQL's :: cast, MySQL's backtick identifiers) passes through without being re-written.

Will this change the query semantics?

No. The formatter only adds/removes whitespace and changes keyword letter case — it never modifies identifiers, string literals, or operator order. The formatted query is semantically identical to the input.

Why are my string literals reformatted?

They aren't — the formatter splits on SQL keywords detected outside of quoted strings. If a keyword appears inside a string literal (e.g. 'SELECT something'), it is not treated as a SQL keyword.

Does it handle comments?

Single-line (--) and block (/* */) comments pass through in Minify mode as-is. In Beautify mode they appear on their own line before the clause they precede.

Is my query sent anywhere?

No. All processing runs locally in your browser with no server involvement.