Presets:
Raw SQL Input
Formatted SQL POSTGRESQL
-- E-commerce monthly revenue and top customer analytics
WITH monthly_summary AS (
SELECT o.customer_id,
DATE_TRUNC('month',
o.order_date) AS order_month,
COUNT(o.id) AS total_orders,
SUM(o.total_amount) AS total_spent
FROM orders o
  INNER JOIN customers c ON c.id = o.customer_id
WHERE o.status = 'completed'
  AND o.order_date >= '2026-01-01'
GROUP BY o.customer_id,
DATE_TRUNC('month',
o.order_date)
HAVING SUM(o.total_amount) > 500)
SELECT c.id,
c.full_name,
c.email,
m.order_month,
m.total_orders,
m.total_spent
FROM monthly_summary m
  LEFT JOIN customers c ON c.id = m.customer_id
ORDER BY m.total_spent DESC,
m.order_month ASC
LIMIT 50
OFFSET 0;

Production-Grade SQL Beautifier

Clean, standardize, and format complex database queries locally in your browser. Handles subqueries, window functions, CTEs, and multi-statement transaction scripts with precision.

Dialect-Aware ArchitectureFormats queries tuned for PostgreSQL, MySQL, SQLite, and Standard ANSI SQL with consistent keyword casing, alignment, and subquery indentation.

Nested Logic & CTEsSubqueries, common table expressions (`WITH`), CASE statements, and JOIN hierarchies are cleanly tiered for optimal readability in pull requests and reviews.

100% Client-Side Air-Gapped PrivacyYour database schemas, query strings, and sensitive table identifiers never touch a network server. Everything runs in your browser.

How to use SQL Formatter

  1. Paste the SQL query you want to make readable.
  2. Choose indentation and keyword casing, then format or minify.
  3. Copy the result and review it in your database's own tooling.

Try an example

select id, name from users where active = true order by name;

A query laid out for easier reading. No database connection is opened and the query is not executed.

What to know before using SQL Formatter

Paste a query and select formatting options. This tool formats text; it does not execute queries or guarantee that SQL is valid for your database.