Lay out an SQL query by dialect

Developers use SQL Formatter before a code review, debugging session or handoff to another contributor.

Lay out an SQL query by dialect, so reviews, edits and debugging become easier. Use it for free in your browser, with no account required.

How to use

  1. Paste the query you want to review into the input area, or import an SQL file from your computer.
  2. Pick the dialect that matches your database: standard SQL, MySQL, PostgreSQL, SQLite, SQL Server or PL/SQL.
  3. Start the formatting so clauses spread over several lines with consistent indentation.
  4. Compare the output with your original to spot a missing clause or a join placed in the wrong spot.
  5. Copy the formatted query into your editor, your ticket or your review notes.

Example

A typical case: a query written as one long line inside a ticket is almost impossible to review. Once formatted, the filtering conditions, the order of the joins and the selected columns become visible at a glance, which makes a colleague's review much faster.

Limits and formats

Where processing happens

The formatting happens entirely in your browser, so the query you paste or import never leaves your machine. No account is required and no copy of your SQL is stored anywhere, which makes the tool suitable for internal queries you would rather not share.

Frequently asked questions

Can I format several queries at the same time?

You can paste whatever you like, but several statements separated by semicolons remain hard to read. Handling one query at a time usually gives the cleanest result and the easiest review.

Does the dialect choice really change the output?

Yes, keywords and constructs differ between engines. Selecting the right dialect avoids misreading syntax that belongs to MySQL, PostgreSQL, SQLite, SQL Server or PL/SQL.

What if the result looks strangely spaced?

Check the string literals and comments in your original query first, since the formatter keeps them. Correct the source rather than the output, then run the formatting again.

Tools in the same category