SQL Formatter

How to use

Beautifies SQL queries by capitalizing keywords and putting each major clause, SELECT, FROM, WHERE, JOIN, GROUP BY, on its own indented line, so long queries are easier to read and review. Paste your query and the formatted version appears.

Developer PopularLocal only

Simple token-based beautifier (uppercases keywords, splits major clauses). Not a full SQL parser.

Indent:
Input SQL
Formatted SQL
SELECT id,
name,
email
FROM  users
INNER
JOIN   orders
ON  users.id = orders.user_id
WHERE  users.active = true AND orders.total > 100
ORDER BY  orders.total DESC
LIMIT  10;
When to use this
  • Turning a dense one-line query pasted from a slow query log into something reviewable
  • Cleaning up a long query with multiple joins before pasting it into a pull request
  • Standardizing keyword casing and indentation across a team's saved queries
  • Making a generated ORM query readable enough to spot an obvious logic issue

Free and private. Everything runs on your own device, with no account and no uploads.

DBAs reviewing a slow query and backend developers pasting a long SQL statement into a code review both benefit from having keywords capitalized and clauses broken onto their own lines. This formatter beautifies SQL queries by placing major clauses like SELECT, FROM, WHERE, JOIN and GROUP BY on separate indented lines with configurable indent size, turning a dense one-line query into something that is actually easy to read and review.

It focuses on formatting and indentation rather than full syntax validation, so it may still format a query that contains a logical or syntax error.

It handles common standard SQL syntax well, but highly dialect-specific extensions may not be formatted with the same precision as a dedicated dialect-aware formatter.

No, it only affects whitespace, line breaks and keyword casing, identifiers like table and column names are left untouched.

Yes, nested subqueries and multiple joins are indented to reflect their structure, though extremely complex queries may need manual review afterward.

How it works
  1. 1

    Paste your SQL query

    Add the raw or minified SQL statement into the input area.

  2. 2

    Choose indentation settings

    Set the indent size and dialect options if available.

  3. 3

    Format the query

    The tool restructures clauses onto separate, indented lines.

  4. 4

    Copy the formatted SQL

    Copy the readable query for your codebase or query tool.

Pro tips
  • ·This formats structure and casing, it does not validate logic, a nicely formatted query can still be wrong.
  • ·Adjust the indent size to match your team's existing SQL style guide before copying the result into a shared file.
  • ·For heavily dialect-specific syntax like T-SQL extensions, review the output manually since formatting precision can vary.