SQL Formatter

Format SQL with clause-aware indentation and consistent keyword casing.

Paste a query to format it.


Result will appear here.

Query summary

Features

  • Clause-aware line breaks and indentation
  • Configurable keyword casing
  • Leading or trailing comma style
  • Compact mode for single-line output
  • Query summary listing tables and clauses

How to use it

  1. Paste your SQL into the input box.
  2. Choose keyword casing and indentation.
  3. Press Format.
  4. Copy the result into your editor or migration file.

Formatting conventions and why they matter

Uppercase keywords are the long-standing convention, and the reason is practical rather than aesthetic: SQL has no visual distinction between keywords and identifiers, so uppercasing SELECT, FROM and WHERE lets you find the structure of a long query at a glance. Table and column names stay lowercase, which makes the two categories immediately distinguishable without syntax highlighting.

Leading commas look strange at first but solve a real problem. When each line begins with a comma, commenting out a column means deleting or commenting one line without touching its neighbours. With trailing commas, removing the last column in a list leaves a dangling comma that breaks the query, a small annoyance that happens constantly while debugging.

The formatting choice that matters most for reviewability is putting each JOIN and each condition on its own line. A five-table join written on one line is unreadable and hides mistakes; the same join with one table per line makes a missing ON clause or an accidental cross join immediately visible. This formatter breaks on the major clause keywords and indents JOIN conditions under their join, which is the convention most style guides converge on.

Frequently asked questions

Yes, completely. SQL Formatter is free with no usage limits, no account and no sign-up. There is no paid tier and no trial that expires. Tools marked Premium on this site carry that label to indicate a deeper feature set, not a price.
SQL Formatter covers clause-aware line breaks and indentation, configurable keyword casing, leading or trailing comma style, among other things. Everything is available immediately with no account, no sign-up and no usage limit.
Uppercase keywords are the long-standing convention, and the reason is practical rather than aesthetic: SQL has no visual distinction between keywords and identifiers, so uppercasing SELECT, FROM and WHERE lets you find the structure of a long query at a glance. Table and column names stay lowercase, which makes the two categories immediately distinguishable without syntax highlighting.
Everything is processed in your browser. Code, tokens and payloads you paste in never leave your device, which matters when you are debugging something that contains real credentials or customer data. Check the Network tab if you want to confirm it. Because nothing depends on a server, the tool also keeps working offline once the page has loaded, the site registers a service worker that caches it after your first visit.

Related tools

Further reading

📖 Why Formatting Your SQL Makes Queries Easier to Read and Debug

Read the full guide on the 123MiniApps blog.

Pick a theme

Ten hand-tuned palettes.