SQL Formatter — Queries You Can Actually Read

Paste a wall of SQL and get back a cleanly formatted query: keywords uppercased, clauses on their own lines, subqueries indented.

100%Free
0Signup Required
0Data Leaves Browser

SQL Formatter

Free • No Signup
Live — results update as you type
0 B input0 B output0% saved

Quick Answer

A SQL formatter takes a dense, single-line query and lays it out so each clause (SELECT, FROM, WHERE, JOIN…) starts on its own line, keywords are uppercased, and parentheses indent properly. Readability without changing what the query does.

What This Tool Does

The formatter tokenizes your SQL — respecting string literals so it never touches their contents — then rebuilds it with your chosen keyword casing, major clauses on fresh lines, commas grouped, and parentheses indented. A trailing semicolon ends cleanly. Advanced options add identifier casing, comment removal and a compact mode.

Key Features

  • Keyword casing — upper, lower, capitalize or unchanged (e.g. select becomes SELECT).
  • Identifier casing — optionally normalize column and table names separately.
  • Clause-per-lineFROM, WHERE, GROUP BY, ORDER BY start their own lines.
  • Indentation options — 1–8 spaces or tabs.
  • Compact mode — fewer line breaks when you want tighter output.
  • Comment removal — strips -- line and /* block */ comments on request.
  • Paren-aware — subqueries indent by depth.
  • String-safe — quoted literals are preserved exactly.
  • Upload file or load from URL — format existing .sql files directly.

How to Use the SQL Formatter

  1. Paste your SQL into the input box, or use Upload File / Load from URL.
  2. Pick a keyword case and indentation style.
  3. Open Show advanced options for identifier casing, comment removal or compact mode.
  4. Read the formatted query on the right — updates live.
  5. Copy or download the result.

Use Cases

  • Reviewing a long query pulled from logs or an ORM.
  • Standardizing query style across a team’s shared snippets.
  • Reading nested subqueries and CTEs without squinting.

Tips

  • String literals containing words like "from" are safe — the formatter tracks quotes.
  • For CTEs, check the indentation of the WITH block once; deep nesting can still be dense.

Privacy

Formatting happens locally — your queries never leave the browser.

Conclusion

SQL is easier to trust when you can read it. Format any query here in seconds — free and private.

FAQ

Frequently Asked Questions About SQL Formatter

No. Only whitespace, line breaks and keyword casing change — the semantics of the query are identical.

The formatter handles common syntax across MySQL, PostgreSQL, SQLite and SQL Server — SELECT/INSERT/UPDATE/DELETE, joins, CTEs and functions.

String literals are tracked and preserved exactly, so a value like 'from now on' is never reformatted.

No — everything runs locally in your browser.

Yes — the Keyword case option offers Upper, Lower, Capitalize or Unchanged. Identifiers can be cased separately in the advanced options.

Yes — tick Remove comments in the advanced options to strip both -- line comments and /* block */ comments.

More Tools

Code Faster, Not Harder

Format, minify, test and generate — free developer utilities that run entirely in your browser.