SQL Formatter

Format SQL queries for MySQL, PostgreSQL, SQL Server, Oracle and more. Free, private and instant: everything runs in your browser.

SQL
Formatted SQL
Press Run to see the result

What does the SQL Formatter do?

A SQL formatter puts each clause (SELECT, FROM, JOIN, WHERE, GROUP BY) on its own line, indents subqueries and conditions and can uppercase keywords. Choose your dialect, such as MySQL, PostgreSQL, T-SQL, PL/SQL, BigQuery or SQLite, for dialect-specific syntax.

How to use the SQL Formatter

  1. 1

    Paste your sql

    Paste or type sql into the input box, open a file from your device, or click Sample to load an example.

  2. 2

    Adjust the options

    Set dialect and keywords and indent to match what you need.

  3. 3

    Copy or download the result

    Review the formatted sql on the right, then copy it to the clipboard or download it as a .sql file.

SQL Formatter example

Input
select u.id,u.name,count(o.id) as orders from users u left join orders o on o.user_id=u.id where u.created_at>='2026-01-01' and u.active=1 group by u.id,u.name having count(o.id)>2 order by orders desc limit 10;
Output
SELECT
  u.id,
  u.name,
  count(o.id) AS orders
FROM
  users u
  LEFT JOIN orders o ON o.user_id = u.id
WHERE
  u.created_at >= '2026-01-01'
  AND u.active = 1
GROUP BY
  u.id,
  u.name
HAVING
  count(o.id) > 2
ORDER BY
  orders DESC
LIMIT
  10;

When to use it

  • •Reading long one-line queries from logs and ORMs
  • •Formatting SQL for code review and docs
  • •Standardising keyword case

Why use this sql formatter

  • 100% free, no signup or login
  • Runs locally: your data never leaves the browser
  • Instant results with clear error messages
  • Works on desktop, tablet and mobile
  • Copy to clipboard or download in one click
  • No watermarks and no usage limits

Frequently asked questions

Is the SQL Formatter free?+

Yes. The SQL Formatter is 100% free with no signup, no login, no usage limits and no watermark. It works on desktop and mobile browsers.

Is my data uploaded when I use the SQL Formatter?+

No. The SQL Formatter runs entirely in your browser with JavaScript. Nothing you paste or upload is sent to our servers, logged or stored.

Last updated by the Imaginex AI team.