Free Tools Grid

SQL Formatter

Developer Tools

Beautify SQL queries across PostgreSQL, MySQL, SQLite, T-SQL, BigQuery, and standard SQL with proper indentation and uppercase keywords.

Runs entirely in your browser
Loading tool...

About SQL Formatter

The SQL Formatter is a dialect-aware pretty-printer for SQL. Whether you're debugging a query generated by an ORM, sharing one in a code review, or just trying to make sense of a JOIN chain that ran together, this tool re-indents it into something readable. It supports six dialects (Standard, PostgreSQL, MySQL, SQLite, T-SQL / MSSQL, and BigQuery), so keywords, identifiers, and special syntax are recognized correctly for your database.

The formatter uses the `sql-formatter` library — the same one many SQL clients embed. It keeps your query semantically identical (no rewriting, no optimization) and simply lays it out one clause per line, indented, with consistent keyword casing. Since everything runs in your browser, query text containing internal schema names, sample data, or production identifiers never leaves your machine.

How to use

  1. 1

    Paste your SQL

    Drop a query of any size into the input editor.

  2. 2

    Choose a dialect

    Pick from Standard SQL, PostgreSQL, MySQL, SQLite, T-SQL (MSSQL), or BigQuery. The right dialect ensures keywords like LIMIT vs TOP, RETURNING, or DATE_TRUNC are handled correctly.

  3. 3

    Set indentation

    Choose 2 or 4 spaces using the Indent dropdown.

  4. 4

    Copy the formatted SQL

    Use Copy or Download to save the formatted query.

Examples

Cleaning a JOIN-heavy query

A one-line query with multiple joins becomes a readable, one-clause-per-line layout.

Input

select u.id, u.name, 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, u.name order by orders desc limit 50;

Output

SELECT
  u.id,
  u.name,
  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,
  u.name
ORDER BY
  orders DESC
LIMIT
  50;

Frequently asked questions

Why are my keywords all uppercase?+

The formatter uppercases SQL keywords by convention — this is the most common style in style guides and matches the output of most database GUIs.

Does it work with stored procedures or PL/pgSQL blocks?+

It formats the SQL parts well. Procedural blocks (BEGIN…END, IF/THEN) are recognized in T-SQL and PostgreSQL but very complex stored procedures may format imperfectly.

Will it rewrite my query for performance?+

No. The formatter never changes query semantics or execution plan. It's purely cosmetic.

Why pick the right dialect?+

Dialects differ on keywords (LIMIT vs TOP, AUTO_INCREMENT vs SERIAL) and special syntax (PostgreSQL's RETURNING, BigQuery's STRUCT). Picking the right one gives accurate keyword highlighting and casing.

Is my SQL sent anywhere?+

No. The query is formatted entirely in your browser via the `sql-formatter` library.