SQL Formatter

Format SQL queries online for MySQL, PostgreSQL, SQL Server, Oracle PL/SQL, SQLite, BigQuery, Snowflake and more. Keyword casing, indentation and minify.

Runs 100% in your browser. Nothing you paste is uploaded.

Input SQL

Formatted SQL

About the SQL Formatter

Long single-line queries from application logs, ORMs or BI tools are difficult to read. The SQL Formatter rewrites them with one clause per line, indented sub-queries and joins, and consistent keyword casing.

It understands dialect-specific syntax for MySQL, MariaDB, PostgreSQL, SQL Server (T-SQL), Oracle PL/SQL, SQLite, BigQuery, Snowflake, Redshift, Spark, DB2, Hive, Trino and more.

Features

  • 15+ SQL dialects
  • UPPER, lower or preserved keyword case
  • Configurable indentation
  • Handles CTEs, sub-queries, CASE and window functions
  • Minify to a single line
  • Keeps comments

How to use it

  1. Choose your database dialect.
  2. Paste the query — formatting happens as you type.
  3. Adjust keyword case or indentation and copy the result.

Frequently asked questions

Does the formatter execute my query?

No. It only parses and re-prints the text. There is no database connection.

What if formatting fails?

Try selecting the correct dialect — vendor-specific syntax (for example T-SQL brackets or PostgreSQL :: casts) is only recognised in the matching mode. The generic “Standard SQL” mode is the strictest.

Can I format multiple statements?

Yes. Separate statements with semicolons; each is formatted and separated by a blank line.

Esc