Skip to content
XUtilHub

SQL Formatter – Beautify SQL Queries Online

Format SQL queries for MySQL, PostgreSQL, SQL Server, Oracle, SQLite, BigQuery and more, with uppercase keywords and clean indentation.

  • Free, no sign-up
  • Runs in your browser, nothing uploaded
Input
Output

About the SQL Formatter

Turn long one-line SQL into readable, well-indented queries. Supports MySQL, MariaDB, PostgreSQL, SQL Server, Oracle PL/SQL, SQLite, BigQuery, Snowflake and Redshift.

Key features

  • 10 SQL dialects
  • Uppercase, lowercase or unchanged keywords
  • Clauses, joins and conditions on separate lines
  • Formats several statements at once
  • Syntax highlighting
  • Private: queries stay in your browser

Make long SQL queries readable

Queries copied from logs, ORMs or application code often arrive on a single line. Format them with each clause, join and condition on its own line so you can read, review and debug them.

Before and after

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

becomes

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

Tips for readable SQL

  • Use table aliases (u, o) consistently.
  • Put each join on its own line with its condition.
  • Prefer explicit joins (LEFT JOIN … ON) over comma joins.
  • Comment complex conditions with --.

JSON formatter, CSV to JSON, and text diff to compare two queries.

How to use the SQL Formatter

  1. Paste your code into the input box, upload a file, or click Sample to try it out.
  2. Choose the options you want, such as indentation, line width or dialect.
  3. The result appears instantly in the output panel. Syntax errors are shown with their line and column.
  4. Click Copy to copy the result, or Download to save it as a file.

Frequently asked questions

Which databases are supported?

Standard SQL, MySQL, MariaDB, PostgreSQL, SQL Server (T-SQL), Oracle PL/SQL, SQLite, BigQuery, Snowflake and Redshift. Pick the dialect so database-specific syntax is recognized.

Does formatting change what the query does?

No. Only whitespace, line breaks and (optionally) keyword case change. Table names, values and string literals stay exactly as written.

Should SQL keywords be uppercase?

It's a style choice; SQL itself isn't case-sensitive for keywords. Uppercase keywords are the most common convention because they stand out from table and column names.

Is it safe to paste production queries?

Yes. Formatting happens entirely in your browser; queries aren't sent to a server or stored.

Is my code uploaded anywhere?

No. Every developer tool runs entirely in your browser, so source code, configuration files and passwords never leave your device.

Which formatter do you use?

HTML, CSS and JavaScript are formatted with Prettier, the most widely used code formatter, so the output matches what most projects use. SQL uses sql-formatter, and minification uses Terser and CSSO.

Is there a size limit?

There's no fixed limit. Very large files (several megabytes) can take a few seconds, depending on your device.

Last updated:

Related Dev tools