SQL Formatter

Paste a raw or minified query and get readable, indented SQL with clause-per-line layout and your choice of keyword casing. Works with common SQL dialects.

Runs entirely in your browser — nothing is sent to our servers.

Query

Formatted

What is SQL formatting?

SQL formatting rewrites a query's whitespace so its structure becomes visible. Each major clause — SELECT, FROM, JOIN, WHERE, GROUP BY, ORDER BY — starts on its own line, the expressions beneath it are indented, and boolean conditions line up underneath the clause they belong to. The query itself is unchanged; only the layout differs.

This matters most for queries you did not write: an ORM-generated statement pulled from a slow-query log, a one-line query copied out of application code, or a report someone emailed you. Reading a 400-character single line to find the join condition is slow and error-prone. Formatted, the same query can be scanned in seconds.

Keyword casing is the other half of readability. Most teams standardise on uppercase keywords with lowercase identifiers so the language and your schema are visually distinct. This tool lets you apply either convention, or leave casing exactly as you typed it.

Why use this SQL formatter

It is fully client-side. Queries often contain table names, column names and literal values that reveal a lot about a production system, so the safest formatter is one that never transmits the query at all. Nothing you paste here leaves your browser.

It is dialect-agnostic by design. Rather than parsing to a specific dialect's grammar, it works on a token level, so Postgres, MySQL, SQLite, SQL Server and BigQuery queries all format sensibly — including quoted identifiers, comments and string literals, which are left untouched.

And it stays out of your way: no account, no query size cap, no ads crowding the editor.

How to use it

  1. Paste your SQL query into the left panel.
  2. Choose whether keywords should be uppercased, lowercased, or left as-is.
  3. Pick an indent width of two or four spaces.
  4. Press Format to beautify, or Minify to collapse the query onto one line.
  5. Press Copy to grab the result, or Clear to reset both panels.

SQL formatter FAQ