SQL Formatter

Format SQL queries for MySQL, PostgreSQL, SQL Server, SQLite, BigQuery and more.

What is a SQL formatter?

A SQL formatter rewrites a query with each clause on its own line, consistent indentation and uniform keyword case, making long or generated SQL easy to read and debug.

Before and after

select id, name from users where active = 1 order by name
SELECT
  id,
  name
FROM
  users
WHERE
  active = 1
ORDER BY
  name

Options

  • Dialect — understands the syntax of each database (backticks in MySQL, :: casts in PostgreSQL, square brackets in SQL Server).
  • Keyword case — UPPERCASE, lowercase or keep as typed.
  • Indent — 2 spaces, 4 spaces or tabs.

Formatting only changes whitespace and keyword case, never the meaning of the query.

Frequently asked questions

Does it run or check my query against a database?

No. It formats the text; it does not connect to any database.

Can it format several queries at once?

Yes, separate them with semicolons.

Is my SQL uploaded?

No, formatting happens in your browser.