SQL Formatter

Turn messy SQL into readable, consistently indented queries. Keywords are uppercased, each major clause goes on its own line, and AND/OR inside WHERE are indented. String literals, quoted identifiers, and comments are never touched, so the output runs exactly like the input. 100% client-side.

Privacy: this tool processes your data entirely in your browser. Nothing you paste or type is sent to the server.

Paste the SQL query to format.

Result

Enter your values and press Calculate — the result appears here.

Worked examples

Simple select

  • sql = SELECT id, name FROM users WHERE active = 1;
  • indent = 2

Result: SELECT id, name FROM users WHERE active = 1;

Join with conditions

  • sql = SELECT u.name FROM users u LEFT JOIN orders o ON o.user_id = u.id WHERE u.active = 1 AND o.total > 100;
  • indent = 2

Result: SELECT u.name FROM users u LEFT JOIN orders o ON o.user_id = u.id WHERE u.active = 1 AND o.total > 100;

Frequently asked questions

Does formatting change what my query does?

No. Only whitespace and keyword case change — string literals, quoted identifiers, numbers, and comments are left exactly as written, so the formatted SQL is equivalent to the input.

How are strings and comments handled?

Single-quoted strings, double-quoted and backtick identifiers, bracket identifiers, and -- and /* */ comments are recognized and preserved verbatim — nothing inside them is modified.

Is my SQL sent to a server?

No. Formatting runs entirely in your browser, so you can safely format queries containing proprietary schema or data.

💬 Discuss on BestWordz Community

Join the conversation about Developer, sql formatter, format sql on the BestWordz Community forum.

Visit Forum →
Copied!