SQL Formatter & Beautifier
Paste any SQL — CTEs, JOINs, window functions — get clean indented output with uppercased keywords.
What it does
A query copied out of an ORM log or pasted from a Slack message is usually a single line of capitalised chaos: 30 joins, nested subqueries, case when then expressions with no indentation to hint at structure.
convert2 uses the open-source sql-formatter library, which understands clause hierarchy and lays the query out so you can see which SELECT belongs to which subquery and which column belongs to which JOIN.
The query stays entirely in your browser. Safe for queries that touch production tables — no SQL ever reaches our server.
How to use it
- Paste the query (one line or many) into the left pane.
- The formatter lays it out with keyword uppercasing and clause indentation.
- Subqueries, CTEs and
CASEexpressions get proper nesting. - Change indent width (2, 4, TAB) from the top-right control.
Example
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 > '2025-01-01' group by u.id, u.name having count(o.id) > 5 order by orders desc;
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 > '2025-01-01'
GROUP BY
u.id,
u.name
HAVING
COUNT(o.id) > 5
ORDER BY
orders DESC;
Why convert2
- Safe for production queries. Nothing leaves your browser. Paste queries that touch customer tables without second-guessing.
- Dialect-aware. Handles standard SQL plus PostgreSQL, MySQL, SQLite, Snowflake, BigQuery idioms.
- CTE and window function support.
WITHblocks andOVER (PARTITION BY …)format correctly. - Keyword casing. Uppercase keywords (
SELECT,WHERE,JOIN) so the structure jumps out. - Diff-friendly. Paired with the diff viewer, it's easy to compare two query variants.
Common use cases
- Formatting a query pulled from a slow query log before sending it to a DBA.
- Cleaning up ORM-generated SQL captured from an application log.
- Reviewing a migration file before committing it.
- Formatting an explain plan result next to the original query.
- Teaching — showing a student what a complex
JOINactually looks like when laid out.
SQL Formatter specifics
- Powered by
sql-formatterv15. Pulled once from jsDelivr, cached by the browser afterwards. - Recognises the
sql(generic) dialect by default — which handles most day-to-day PostgreSQL, MySQL and SQLite queries. - Does not execute the query. It's a text formatter.
- Comments (both
--and/* */) are preserved. - For dialect-specific quirks (
#commentin MySQL,::typecasts in PostgreSQL), the default dialect works well for the majority of cases.
Frequently asked questions
Which SQL dialects are supported?
Standard SQL plus PostgreSQL, MySQL and SQLite. The formatter handles CTEs, window functions, JOINs, subqueries and CASE expressions correctly.
Is it safe for production queries?
Yes. The SQL you paste stays in your browser and is never sent anywhere.
Can I choose indent width?
Yes — 2 spaces, 4 spaces or tabs, selectable from the top-right indent control.
Does it run the query?
No, this is strictly a text formatter. It doesn't connect to any database.
What about stored procedures or triggers?
Long procedural SQL (PL/pgSQL, T-SQL) formats, but the formatter focuses on clause hierarchy — procedural structure may not be its strong suit.