Skip to content
</>Inblix Dev ToolsAll tools

SQL Formatter Online

Turn a dense one-line query into something you can review. Each clause goes on its own line and keywords are upper-cased, while text inside string literals is left exactly as written.

How it works

This formatter rearranges layout only. It does not parse or validate your SQL, so it will happily format a statement that would fail if you ran it. Use it to make a query reviewable, not to check whether it is correct.

String literals are protected from the keyword pass. A query containing `WHERE status = "select from"` will not have that string rewritten, which matters because keywords inside quotes are data, not syntax. Both single-quoted literals and doubled single quotes for escaping are handled.

One clause per line is chosen because it is the layout that survives review. A 400-character WHERE clause on one line is hard to read and easy to get wrong; split across lines, a diff shows exactly which predicate changed.

The keyword list covers the common SQL dialect: DML, DDL, joins, grouping, set operations, and the conditional keywords. Dialect-specific additions — window functions such as OVER, CTEs written with WITH, and database-specific functions — are laid out as ordinary tokens rather than being given their own line.

Because it is a regex-based formatter rather than a dialect parser, very unusual syntax will not be formatted ideally. For anything you will maintain long-term, running the result through a real formatter such as sql-formatter or your editor plugin is still worthwhile.

Use the SQL Formatter

Formatted SQL
Paste sql on the left to see the result.

Try an example:

Runs entirely in your browser — nothing you paste is uploaded or logged.

Worked examples

Real input and the exact output this page produces.

Example 1

SQL

                      select u.id, u.name from users u join orders o on o.user_id = u.id where o.total > 100 order by o.total desc
                    

Formatted SQL

                      SELECT
  u.id,
  u.name
FROM
  users u
JOIN
  orders o
  ON o.user_id = u.id
WHERE
  o.total > 100
ORDER BY
  o.total DESC;
                    

Frequently asked questions

Does it check my SQL is valid?

No. It reformats the text without parsing it. A statement with a syntax error will still be laid out, just not usefully.

Are string literals modified?

No. Text inside single quotes is masked before keywords are upper-cased and restored afterwards, so queries containing words like select inside a literal are safe.

Which SQL dialects are supported?

The formatter is dialect-agnostic and keyword-driven. Standard DML and DDL format well; dialect-specific syntax is laid out as ordinary tokens.

Others doing similar work.