Messy input
select id,name,email from users u join orders o on o.user_id=u.id where u.active=1 and o.total>100 order by o.total desc;The SQL Formatter takes minified, inconsistently indented, or single-line SQL and rewrites it into clean, readable statements. It capitalizes keywords, aligns clauses like SELECT, FROM, WHERE, JOIN, and GROUP BY onto their own lines, and indents nested subqueries. Everything runs locally in your browser, so even production queries containing schema names stay on your machine and are never sent to a server.
SQL (Structured Query Language) is the standard language for querying and manipulating relational databases such as PostgreSQL, MySQL, SQLite, and SQL Server. Because SQL is often written inline in application code or generated by ORMs, it frequently arrives as one long line. Consistent formatting makes complex joins and conditions far easier to review, debug, and maintain, and helps teams agree on a shared style during code review.
The main file is the entry point for each run.
Use the Input panel to pipe standard input to your program when it needs data.
Run sends your code to a fresh hosted runtime and streams the result into the output panel.
Your draft stays in this browser, and Share creates a separate snapshot link.
select id,name,email from users u join orders o on o.user_id=u.id where u.active=1 and o.total>100 order by o.total desc;SELECT
id,
name,
email
FROM
users u
JOIN orders o ON o.user_id = u.id
WHERE
u.active = 1
AND o.total > 100
ORDER BY
o.total DESC;SELECT
name
FROM
products
WHERE
category_id IN (
SELECT
id
FROM
categories
WHERE
active = 1
);select dept,count(*) c,avg(salary) avg_sal from employees where hire_date>'2020-01-01' group by dept having count(*)>3 order by c desc;SELECT
dept,
COUNT(*) c,
AVG(salary) avg_sal
FROM
employees
WHERE
hire_date > '2020-01-01'
GROUP BY
dept
HAVING
COUNT(*) > 3
ORDER BY
c DESC;INSERT INTO
users (name, email, active)
VALUES
('Ada', '[email protected]', 1);
UPDATE
users
SET
active = 0,
updated_at = NOW()
WHERE
id = 42;WITH ranked AS (
SELECT
id,
dept,
salary,
ROW_NUMBER() OVER (
PARTITION BY dept
ORDER BY salary DESC
) AS rn
FROM
employees
)
SELECT
id,
dept,
salary
FROM
ranked
WHERE
rn = 1;select o.id,c.name,p.title from orders o join customers c on c.id=o.customer_id left join products p on p.id=o.product_id where o.status='paid';SELECT
o.id,
c.name,
p.title
FROM
orders o
JOIN customers c ON c.id = o.customer_id
LEFT JOIN products p ON p.id = o.product_id
WHERE
o.status = 'paid';DELETE FROM
sessions
WHERE
expires_at < NOW()
AND user_id NOT IN (
SELECT
id
FROM
users
);The editor uses Monaco, the engine behind VS Code, with language-aware editing tools and familiar keyboard controls.
Paste a minified or single-line SQL statement and get a clean, readable query back.
Major clauses like SELECT, FROM, WHERE, JOIN and GROUP BY move onto their own lines.
Nested subqueries are indented so the query structure is obvious at a glance.
Reserved keywords are normalized to uppercase for a consistent style.
Column lists and ON conditions are aligned under their clauses.
Works with dialects like PostgreSQL, MySQL, SQLite and SQL Server.
Formatting runs entirely in your browser, so queries are never sent to a server.
Even production SQL with real schema and table names stays on your machine.
Copy the formatted query in one click to paste back into your editor.
Great for tidying ORM-generated SQL before a code review.
Output
Start typing to auto-process