ToolSink

SQL Formatter

Format SQL queries into clean, readable multi-line syntax. Supports MySQL, Postgres, T-SQL, BigQuery and more.

What is the SQL Formatter?

The SQL Formatter takes a jumbled one-line SQL query and reformats it into readable, multi-line syntax with proper indentation, keyword casing and clause alignment. It supports popular dialects like MySQL, PostgreSQL, SQL Server, SQLite, BigQuery and Oracle.

Ugly SQL is a hidden productivity killer. A 400-character SELECT joined to five tables is nearly impossible to review during a pull request. A well-formatted version reads top-to-bottom like prose and reveals bugs, missing joins and forgotten WHERE clauses.

The formatter runs 100% in your browser. Your queries — including production ones you might be debugging — never travel to a third-party service.

How to use the SQL Formatter

  1. 1Paste your SQL query into the input area.
  2. 2Pick the database dialect (MySQL, PostgreSQL, SQL Server, etc.).
  3. 3Choose an indentation width (2 spaces, 4 spaces or tab).
  4. 4Optionally set keyword casing (upper, lower or preserve).
  5. 5Click "Format" and read the tidied version.
  6. 6Copy the formatted query back to your editor.

Key features

  • Support for MySQL, PostgreSQL, SQL Server, SQLite, BigQuery, Oracle
  • Configurable indentation and keyword case
  • Aligns SELECT columns, JOIN conditions and WHERE clauses
  • Handles subqueries and CTEs
  • Preserves comments
  • Runs offline in the browser

Examples

One-liner to readable

Input
select u.id, u.name, count(o.id) as orders from users u left join orders o on u.id=o.user_id where u.active=1 group by u.id, u.name order by orders desc limit 20;
Output
SELECT
  u.id,
  u.name,
  COUNT(o.id) AS orders
FROM users u
  LEFT JOIN orders o ON u.id = o.user_id
WHERE u.active = 1
GROUP BY u.id, u.name
ORDER BY orders DESC
LIMIT 20;

Why use this tool

  • Turns hard-to-read SQL into reviewable code
  • Speeds up debugging and code review
  • Enforces consistent style across a team
  • Supports many dialects without extra setup
  • Your queries stay private

Common use cases

  • Preparing queries for a pull request
  • Documenting complex reports
  • Teaching SQL classes
  • Formatting queries pasted from an ORM log
  • Standardising code style across a team
  • Reformatting queries copied from BI tools

Frequently asked questions

Does the formatter change my results?

No — it only rearranges whitespace and casing. The query still executes identically.

Which dialects are supported?

MySQL, PostgreSQL, SQL Server, SQLite, BigQuery, Oracle, MariaDB and standard ANSI SQL.

Can it format stored procedures?

Yes — DECLARE, IF/ELSE and LOOP constructs are handled for popular dialects.

Is my SQL uploaded?

No. Formatting happens in the browser using a bundled formatter library.

Does it minify SQL too?

Yes — pick the minify option to collapse whitespace.