Beautify SQL queries with consistent indentation and keyword styling.

Formatted SQL

Run the tool to see the result here

Overview

SQL Formatter cleans up ad-hoc queries with consistent indentation, spacing, and keyword casing so you can reason about joins and filters faster. It helps teams keep SQL snippets review-friendly whether they come from ORMs, BI tools, or production logs.

Use Cases

Code review ready SQL

Keep pull requests focused on business logic by presenting SQL with aligned SELECT lists and WHERE blocks for reviewers.

Analytics and debugging clarity

Reformat production queries pulled from logs so you can visually trace joins, filters, and aggregations while debugging dashboards or API calls.

Knowledge sharing and docs

Publish documentation, onboarding guides, or lunch-and-learn slides with consistent SQL samples that match your team's style guide.

Normalize generated SQL

Normalize captured SQL before committing it to repositories to avoid noisy diffs produced by different editors or database consoles.

How to Use

  1. Paste your SQL

    Paste a single query or multiple statements from editors, BI exports, or ORM logs into the input box.

  2. Choose formatting options

    Pick indentation width, keyword casing, and whether JSON literals should be pretty-printed. The preview updates instantly as you tweak the source.

  3. Copy or refine the result

    Copy the formatted output or adjust the input and rerun. The details panel shows line and byte counts for quick sharing.

Frequently Asked Questions

Does the formatter change query behaviour?

No. Formatting only adjusts whitespace and keyword casing—all identifiers, literals, parameters, and comments remain intact.

Will keyword casing touch quoted identifiers?

Quoted identifiers, string literals, and JSON keys stay exactly as written. Only recognised SQL keywords change case.

Can it handle multiple statements?

Yes. Separate statements with semicolons; each block is preserved with a blank line so you can review them independently.

Related Tools

External Resources