SQL Formatter
Format messy SQL into clean, readable queries.
Format, minify, and beautify SQL queries
How to use it
- 1Paste your SQL query into the editor.
- 2Click Format for readable, indented SQL, or Minify to collapse it to one line.
- 3Toggle uppercase keywords on or off and pick 2- or 4-space indentation.
- 4Check the detected statement type, join count, and clause count below the output, then copy the result.
Supported formats & limits
Works with standard syntax — no file size limit, since everything runs in your browser.
Example
A one-line query with a join, a CASE expression, a group by, and a limit gets broken into clearly indented clauses — each selected column, join, WHEN branch, and condition on its own line — or collapsed into a single compact line with Minify.
How it works
Your query is tokenized into keywords, identifiers, strings, and punctuation, then rebuilt with a new line for each major clause (SELECT, FROM, WHERE, JOIN, GROUP BY, and more), indented column and condition lists, nested CASE/WHEN/ELSE/END blocks, and optional uppercase keywords with your choice of 2- or 4-space indentation — entirely in your browser, without sending your SQL anywhere. It's a lightweight formatter rather than a full SQL parser, so deeply nested or unusual syntax may not format perfectly.