SQL Formatter & Beautifier
Paste SQL to format with keyword uppercasing, custom indentation, and dialect support
Paste a messy one-liner SQL query, hit Format, and get clean indentation with uppercased keywords — works with MySQL, PostgreSQL, SQLite, and standard SQL. And everything runs in your browser. Nothing gets uploaded.
How It Works
The parser breaks your SQL into tokens — keywords, identifiers, operators, literals. Then it rebuilds the query with proper indentation based on clause depth. SELECT columns get their own lines, JOINs indent under FROM, and nested subqueries shift right. You pick the dialect, tab size, and whether keywords should be uppercase or lowercase.
Examples
Basic SELECT with WHERE
Someone dumped a one-liner query in Slack and you need to actually read it.
select id, name, email from users where status = 'active' and created_at > '2024-01-01' order by name asc limit 50;
SELECT
id,
name,
email
FROM
users
WHERE
status = 'active'
AND created_at > '2024-01-01'
ORDER BY
name ASC
LIMIT
50;
Multi-table JOIN
A report query joining three tables — unformatted, it's almost impossible to trace the relationships.
select o.id, c.name, p.title, o.total from orders o inner join customers c on o.customer_id = c.id left join products p on o.product_id = p.id where o.total > 100 and c.country = 'US';
SELECT
o.id,
c.name,
p.title,
o.total
FROM
orders o
INNER JOIN customers c
ON o.customer_id = c.id
LEFT JOIN products p
ON o.product_id = p.id
WHERE
o.total > 100
AND c.country = 'US';
Subquery with GROUP BY
Nested queries are where formatting really saves you. Without indentation, matching parentheses is guesswork.
select department, avg_salary from (select department, avg(salary) as avg_salary from employees group by department) sub where avg_salary > 75000 order by avg_salary desc;
SELECT
department,
avg_salary
FROM
(
SELECT
department,
AVG(salary) AS avg_salary
FROM
employees
GROUP BY
department
) sub
WHERE
avg_salary > 75000
ORDER BY
avg_salary DESC;
Who Uses This
Clean up auto-generated ORM queries before pasting them into bug reports or documentation.
Format slow-query log output so they can spot missing indexes and inefficient joins fast.
Make 200-line reporting queries readable before sharing with teammates for review.
See proper SQL structure while learning — formatted queries are way easier to study than wall-of-text ones.
Common Mistakes
MySQL uses backticks for identifiers, PostgreSQL uses double quotes. If your formatting looks off or breaks around quoted names, switch to the correct dialect in the dropdown.
Pasting multiple queries without semicolons at the end of each one? The formatter treats everything as a single statement. Add a semicolon after each query so they get formatted separately.
This formats your SQL — it does not check if it's valid. A query with a typo in a column name will still get neatly indented. Run it against your database to catch actual errors.
Technical Details
- Processing: 100% client-side — your SQL never leaves the browser
- Browser Support: Chrome, Firefox, Safari, Edge
- Dialects: Standard SQL, MySQL, PostgreSQL, SQLite
- Options: Tab size (2/4), keyword case (upper/lower), lines between queries
Frequently Asked Questions
How do I format SQL online for free?
Paste your SQL into the input box, pick your dialect, and hit Format. That's it — no signup, no limits. The result shows up instantly on the right side, ready to copy.
What's the difference between SQL formatter and SQL beautifier?
Same thing, different name. Both add indentation, line breaks, and consistent keyword casing to your SQL. Some tools call it "beautify," others call it "format." The output is identical.
Does formatting SQL change how the query runs?
No. Formatting only adds whitespace and changes letter casing on keywords. The database ignores all of that. Your query runs exactly the same before and after formatting.
Can I format PostgreSQL-specific syntax like dollar quoting?
Yes. Switch the dialect dropdown to PostgreSQL. It handles dollar-quoted strings ($$...$$), type casts with ::, and other Postgres-specific syntax correctly. Using the wrong dialect may break the formatting around those parts.
Is it safe to paste production SQL into an online formatter?
With this tool, yes. Your SQL is processed entirely in your browser using JavaScript. Nothing gets sent to a server. Close the tab and it's gone — no logs, no storage, no tracking of your queries.