SQL formatter and beautifier

Paste a SQL query to give it clean indentation, consistent keyword capitals and one clause per line. Choose your database dialect, or minify the query onto a single line.

Result

How to use the SQL formatter

  1. Paste your SQL into the left box, or click Open File.
  2. Choose the dialect that matches your database, plus keyword case and indent size.
  3. Click Copy or Download to take the formatted query.

Before and after

select c.name, count(o.id) as orders, sum(o.total) as revenue from customers c left join orders o on o.customer_id = c.id where o.created_at >= '2026-01-01' group by c.name having sum(o.total) > 1000 order by revenue desc limit 10;

becomes

SELECT
  c.name,
  count(o.id) AS orders,
  sum(o.total) AS revenue
FROM
  customers c
  LEFT JOIN orders o ON o.customer_id = c.id
WHERE
  o.created_at >= '2026-01-01'
GROUP BY
  c.name
HAVING
  sum(o.total) > 1000
ORDER BY
  revenue DESC
LIMIT
  10;

Why format SQL?

  • Readable reviews. One clause per line makes a pull request diff show exactly what changed.
  • Faster debugging. A missing join condition or a misplaced bracket stands out once the query is indented.
  • Understanding generated SQL. Queries logged by an ORM or copied from a monitoring tool arrive as one long line.
  • Consistency. A team that agrees on keyword case and indentation spends less time arguing about style.

Why the dialect matters

Databases disagree on details: MySQL quotes names with backticks, SQL Server uses square brackets, PostgreSQL has :: casts and $1 parameters, and each has its own keywords. Picking the right dialect lets the formatter read those correctly. If a query fails to format, try Standard SQL or the dialect it was written for.

The formatter only changes spaces, line breaks and keyword case. It does not check that tables exist or run anything. To try a query for real, use the SQL playground, which runs SQLite in your browser.

Private by design

This tool runs entirely in your web browser. Nothing you type or paste is sent to a server, logged or stored, so it is safe to use with internal addresses, configuration files and other work data. There is no sign-up and it keeps working offline once the page has loaded.

Frequently asked questions

How do I format a SQL query?

Paste it into the left box. The formatted version appears on the right as you type.

Does formatting change what my query does?

No. Only spaces, line breaks and the capitals of keywords change.

Which databases are supported?

MySQL, MariaDB, PostgreSQL, SQLite, SQL Server, Oracle, BigQuery, Snowflake, Redshift, Spark, DB2, Hive and Trino, plus standard SQL.

Can I minify SQL?

Yes. Set Output to Minified to remove comments and line breaks and put each statement on one line.

Is my SQL sent to a server?

No. Formatting runs in your browser.