SQL Formatter

Turn messy SQL into clean, readable queries with consistent indentation and keyword case.

Free, no sign-upRuns in your browserWorks on any device
0
Input Length
0
Output Length
0%
Compression
SQL Input Paste SQL query here
Formatted Output Copy to clipboard
Waiting for input...

About the SQL Formatter

Long SQL queries written on one line are hard to read and debug. The SQL Formatter adds line breaks and indentation for clauses, joins and conditions and can uppercase keywords for consistency.

It is handy for code reviews, documentation and debugging generated queries.

How to use the SQL Formatter

  1. Paste your SQL query.
  2. Choose formatting options such as keyword case.
  3. Click format.
  4. Copy the formatted query.

Key features

  • Clause-based indentation
  • Uppercase keywords
  • Minify option
  • Syntax highlighting

What good SQL formatting looks like

Readable SQL puts each major clause (SELECT, FROM, JOIN, WHERE, GROUP BY, ORDER BY) on its own line, lists selected columns one per line and indents conditions under the clause they belong to. Uppercasing keywords separates the language from table and column names at a glance. Teams that format consistently find errors faster in code reviews.

The formatter changes only whitespace and keyword case. It does not run, rewrite or optimise your query, so the formatted version returns exactly the same results.

Common uses

  • Making long one-line queries from logs or ORMs readable.
  • Preparing SQL for code reviews and documentation.
  • Debugging complex joins and subqueries.
  • Minifying queries for embedding in application code.

Tips for the best results

  • Format before reviewing a query generated by an ORM; it is much easier to spot missing join conditions.
  • Keep one column per line so version control diffs show exactly what changed.
  • Use table aliases consistently across a query.
  • Paste formatted queries into documentation or tickets so reviewers can follow the logic clause by clause.

Frequently asked questions

Which SQL dialects are supported?

Standard SQL used by MySQL, PostgreSQL, SQL Server and SQLite formats well.

Does it run or validate my query?

No. It only formats the text and does not connect to any database.

Is my query private?

Yes. Formatting happens in your browser.

Does it check my SQL for errors?

It formats the text but does not validate it against a database. Run the query in your database tool to check it.

Is my query uploaded?

No. Formatting happens in your browser.

Can I format several queries at once?

Yes. Paste queries separated by semicolons and each is formatted in turn.

Related developer tools

View all →