← Back to all browser tools
DEVELOPER TOOL / 73

Format SQL.
Read the query.

Turn a dense SQL query into a readable, copy-ready layout — keywords uppercased, clauses on their own lines, joins indented. Your query stays in the browser.

How do I format SQL online? Paste a query to get readable indentation and clauses; common dialects are supported best-effort.

SQL formatter

The part a formatter must never touch is the case inside a quoted identifier — the dialect differences and the join layout are in our guide to formatting SQL.

Best-effort formatting · no execution

This formatter changes whitespace and keyword casing only. It does not parse, validate, execute, or rewrite your SQL logic; review the result before running it.

What the beautifier does to your query

Before and after

-- before
select o.id, u.name, sum(oi.price*oi.qty) as total from orders o
join users u on u.id=o.user_id join order_items oi on oi.order_id=o.id
where o.created_at > '2026-01-01' and o.status in ('paid','shipped')
group by o.id, u.name having sum(oi.price*oi.qty) > 100 order by total desc limit 20;

-- after
SELECT o.id, u.name, SUM(oi.price * oi.qty) AS total
FROM orders o
JOIN users u ON u.id = o.user_id
JOIN order_items oi ON oi.order_id = o.id
WHERE o.created_at > '2026-01-01' AND o.status IN ('paid', 'shipped')
GROUP BY o.id, u.name
HAVING SUM(oi.price * oi.qty) > 100
ORDER BY total DESC
LIMIT 20;

How to beautify SQL

  1. Paste your query — long one-liners and dumps from logs are exactly the point.
  2. Format — keywords, clauses, and nesting get normalized instantly.
  3. Copy the result — straight into code review, a ticket, a runbook, or your editor.

Why format SQL at all

Good to know

Formatting changes whitespace only — the query behaves exactly the same, but always skim your comments after any reformat. Dialects vary wildly, so this is labeled best-effort: common syntax formats identically across MySQL, PostgreSQL, SQLite, and SQL Server, while vendor-specific constructs pass through unchanged. For very large migration files, paste one statement at a time for the cleanest result. And because queries contain real table and column names, the local-only processing matters: nothing is ever sent to a server.

Advertisement
QUICK ANSWERS
Which SQL dialects work?

Common syntax used across MySQL, PostgreSQL, SQLite, and SQL Server — SELECT/INSERT/UPDATE/DELETE, joins, subqueries, CTEs, and window functions — formats well. Vendor-specific constructs are preserved unchanged on a best-effort basis.

Does formatting change how the query runs?

No — only whitespace changes. String literals are never touched and comments are preserved, so the reformatted query executes identically. Do skim your comments after reformatting, since line wrapping can move them.

Does it support private queries?

Yes. Formatting happens locally and the page never sends query text to a server — which matters when the query contains real table names, customer columns, or anything under NDA.

Why is this called best effort?

SQL dialects have vendor-specific grammar. This page formats common statements and clause structures but is not a full dialect-aware parser — unusual syntax passes through rather than breaking.

Can I beautify a whole migration file?

Paste one statement at a time for the cleanest result. The formatter works on any text, but very large multi-statement files are easier to review when formatted piece by piece.