Skip to content
ToolzKit

Developer

SQL Formatter

Reformat SQL queries with clause-based line breaks and consistent keyword casing.

Input

Paste SQL

Output

Formatted SQL appears here.

Paste a SQL query above, or load the example.

About the SQL Formatter

This formatter breaks a SQL statement onto new lines at major clause boundaries such as SELECT, FROM, WHERE and JOIN, indents nested subqueries by parenthesis depth, and optionally uppercases keywords. It helps developers turn dense, single-line queries into something readable during code review.

How to use it

  1. 01Paste your SQL query into the input panel.
  2. 02Toggle whether keywords should be uppercased.
  3. 03Review the reformatted query on the right.
  4. 04Copy or download the result as a .sql file.

Features

  • Line breaks before SELECT, FROM, WHERE, JOIN variants, GROUP BY, ORDER BY, HAVING, LIMIT and DML clauses
  • Indentation of subqueries based on parenthesis nesting depth
  • String literals are kept intact and never altered
  • Optional uppercase keyword formatting

Practical examples

Cleaning up a generated query

Paste a single-line query produced by an ORM or query builder to make it readable for a pull request or debugging session.

Limitations

  • This is a lightweight token-based formatter, not a full SQL parser, so unusual dialect-specific syntax may not break exactly where expected.
  • It does not validate query correctness or catch SQL syntax errors.

Privacy

All formatting happens locally in your browser using a custom formatter; no query text is sent anywhere.

Read the full privacy policy for how the site as a whole handles data.

Frequently asked questions

Does it support all SQL dialects?

It handles common ANSI SQL clauses used across MySQL, PostgreSQL, SQLite and SQL Server, but dialect-specific extensions may not be recognized as clause boundaries.

Will it fix an invalid query?

No, it reformats whitespace and casing only; it cannot detect or repair syntax errors.

Does it touch string literals?

No, text inside single or double quotes is copied through unchanged, including any keywords that happen to appear inside a string.