SQL Formatter

Format SQL for PostgreSQL, MySQL, SQL Server or Oracle PL/SQL. Only whitespace changes: the query is never executed.

Options

Input

Up to 1 MiB. The file is not uploaded: it is read in your browser.

Ctrl + Enter to run

Result

Format SQL queries with consistent line breaks and indentation for PostgreSQL, MySQL, SQL Server (T-SQL) or Oracle (PL/SQL). Keywords can be uppercased, lowercased or preserved.

The formatter only rewrites whitespace and, if requested, keyword case: literals, identifiers and comments are kept. The query is never executed or sent to a database.

How to use it

  1. Paste the SQL or open a .sql file.
  2. Choose the dialect and style.
  3. Press Run.

Example

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.created_at >= '2025-01-01' and u.active = true group by u.id, u.email order by orders desc limit 10;
Result
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.created_at >= '2025-01-01'
  AND u.active = TRUE
GROUP BY
  u.id,
  u.email
ORDER BY
  orders DESC
LIMIT
  10;

Limitations

  • It does not check the query against your schema.
  • Highly vendor-specific syntax may not be recognized; try the closest dialect.
  • 1 MiB limit (512 KiB on mobile).

FAQ

Does it change what my query returns?
It should not: only whitespace, line breaks and optionally keyword case change. Always review the result before using it in production.
Does it connect to my database?
No. There is no connection or execution: everything happens in your browser.

Related tools

References