GenerateIt

SQL Formatter

Need to make a SQL query easier to read and understand? This tool formats raw SQL into a clean, consistently structured layout, with improved indentation, SQL keywords capitalized, and major clauses arranged on separate lines. Whether you're tidying up a complex query, reviewing database code, debugging a statement, or preparing SQL for documentation, it helps make your code more readable and easier to maintain. The formatted output updates live as you type.

Simply paste your SQL query to see the formatted version, ready to copy into your editor or project. Everything is processed directly in your browser, with nothing sent to a server, keeping your queries private and under your control.

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong.

Buy me a coffee

SQL Formatter

Raw SQL
Formatted

Formatting happens in your browser. Nothing is uploaded.

How to use it

The SQL formatter tidies up a raw query so it's easier to read and review.

  1. Paste your queryPut the raw SQL into the left box.
  2. Read the resultThe formatted version appears automatically on the right, with each clause on its own line.
  3. Copy itUse the Copy button beside the formatted box.

Good to know

Nothing is uploaded

Formatting happens entirely in your browser.

Keywords are capitalized

Words like SELECT, FROM and WHERE are uppercased; your table and column names are left exactly as typed.

Works best on one query

This tool is built for a single SELECT, INSERT, UPDATE or DELETE statement at a time, including simple subqueries.

Frequently asked questions

Does this change what my query does?

No. It only changes whitespace, line breaks and the capitalization of SQL keywords — the query's logic, table names and column names are untouched.

Which SQL dialect does it support?

It works on standard ANSI SQL syntax shared by MySQL, PostgreSQL, SQL Server and SQLite — common clauses like SELECT, JOIN, WHERE, GROUP BY and ORDER BY. Dialect-specific extensions are passed through unformatted rather than rejected.

Why didn't a nested subquery get indented?

Subqueries that start with SELECT are formatted and indented on their own. Other parenthesized expressions, like a list of values in an IN (...) clause, are kept on one line to stay compact.

Is my SQL uploaded anywhere?

No. Formatting runs locally in your browser.

Related tools

Diff Checker

Compare two blocks of text and see what changed.

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong.

Buy me a coffee