SQL Formatter

Turn a long one-line SQL query into clean, indented SQL that is easy to read and review. Pick your database dialect and keyword style.

Loading tool…

How to use the SQL Formatter

  1. Paste your SQL query (one or many statements).
  2. Choose the SQL dialect, keyword case and indent.
  3. Copy the formatted SQL or download it as a .sql file.

Formatting runs in your browser using the open-source sql-formatter library (downloaded once when you open this page).

Frequently asked questions

Which databases are supported?

Standard SQL, MySQL, PostgreSQL, SQL Server (T-SQL), Oracle PL/SQL, SQLite and Google BigQuery. Pick the one you use so its special syntax is understood.

Will formatting change what my query does?

No. Only spaces, line breaks and (if you choose) keyword letter case change. Strings, names and values stay exactly as written.

Why do I see a formatting error?

The formatter could not understand part of the query. Check for a missing quote or bracket, or try a different dialect — for example, use T-SQL for square-bracket names.

Is my query sent to a server?

No. The formatter runs in your browser, so queries with table names or data stay private.