Skip to main content

SQL Formatter

Runs locally

Format SQL queries across PostgreSQL, MySQL, SQLite, BigQuery, Snowflake and T-SQL.

What is SQL Formatter?

Beautify or compact SQL queries across Standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, BigQuery, Snowflake, T-SQL, PL/SQL, and Redshift. Control keyword casing, indentation, logical operator placement, and comma styles.

How to use SQL Formatter

  1. Step 1

    Paste your SQL query or DDL statement into the input editor.

  2. Step 2

    Select your SQL dialect (PostgreSQL, MySQL, SQLite, BigQuery, etc.) and formatting style in Options.

  3. Step 3

    Review syntax errors if a clause is malformed.

  4. Step 4

    Copy the formatted SQL or download as a .sql file.

Features

  • Supports 10+ SQL dialects including PostgreSQL, MySQL, SQLite, BigQuery, Snowflake, T-SQL, PL/SQL
  • Keyword casing options: UPPERCASE, lowercase, or preserve
  • Configurable tab width (2/4 spaces or tabs) and logical operator placement (before/after)
  • Tabular or compact expression alignment and query minify mode
  • Supports parameterized placeholders ($1, :name, ?)
  • Runs locally in your browser with zero query logging

Example

Input

select u.id,u.email,count(o.id) as orders from users u left join orders o on o.user_id=u.id where u.active=true group by u.id order by orders desc;

Output

SELECT
  u.id,
  u.email,
  count(o.id) AS orders
FROM
  users u
  LEFT JOIN orders o ON o.user_id = u.id
WHERE
  u.active = TRUE
GROUP BY
  u.id
ORDER BY
  orders DESC;

Uppercases SQL keywords, aligns joins and clauses, and indents selected columns.

Frequently asked questions

Which SQL dialects are supported?

Standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, BigQuery, Snowflake, T-SQL (SQL Server), PL/SQL, and Redshift.

Are my production SQL queries uploaded?

No. Formatting executes completely in your browser.

Can it format queries with bind parameters like $1 or :id?

Yes, PostgreSQL ($1), named (:id), and positional (?) placeholders are preserved.

Can I minify SQL back to one line?

Yes, enable Minify mode in Options to collapse whitespace safely while preserving string literals.