SQL Formatter

Turn a long one-line query into readable, consistently indented SQL.

How to format SQL

  1. Paste SQL or open a .sql file.
  2. Choose the dialect, keyword case and layout.
  3. Copy or download the formatted SQL.

About SQL Formatter

Format SQL queries for 16 dialects.

Everything works in your browser, so it is instant and private, and your settings are remembered on this device.

Good for

  • Reading long queries and ORM output
  • Code reviews and documentation
  • Cleaning up queries copied from logs

Tip: Put AND / OR at the start of lines — it makes it easy to comment out one condition.

Frequently asked questions

Which databases are supported?

Standard SQL, MySQL, MariaDB, PostgreSQL, SQL Server (T-SQL), Oracle PL/SQL, SQLite, BigQuery, Snowflake, Redshift, Spark, Trino/Presto, Db2, Hive, Couchbase N1QL and SingleStore.

Why does my query show an error?

The formatter understands each dialect’s syntax. If you get a parse error, choose the right dialect — for example backticks need MySQL and [brackets] need SQL Server.

Can it change keyword case?

Yes — keywords, function names and identifiers can each be UPPER, lower or kept as written.

Is my SQL sent to a server?

No — formatting happens in your browser, so queries with table names and data stay private.

Does formatting change what my query does?

No — only whitespace, line breaks and keyword case change. Changing identifier case can matter in databases with case-sensitive names, so leave it off if you're unsure.

Related tools

← Back to all tools