How to use it
Paste your SQL on the left and the formatted version appears on the right. Pick the dialect your database speaks from the list, then choose how keywords should look and how far to indent. Press ⌘ Enter to format and Shift ⌘ Enter to minify. Your settings are saved in the page link, so you can bookmark your team’s style.
If the formatter can’t make sense of the query, the problem is underlined in your SQL and explained in the status bar. Click “Show in input” to jump to it.
A worked example
A one-line query is hard to scan:
select u.id, u.email, count(o.id) as orders from users u left join orders o on o.user_id = u.id where u.created_at >= '2026-01-01' group by u.id, u.email order by orders desc;Formatted for PostgreSQL with upper-case keywords and a 2-space indent, each clause gets its own line and each column its own row, so you can see at a glance what’s selected, joined and filtered:
SELECT
u.id,
u.email,
COUNT(o.id) AS orders
FROM
users u
LEFT JOIN orders o ON o.user_id = u.id
WHERE
u.created_at >= '2026-01-01'
GROUP BY
u.id,
u.email
ORDER BY
orders DESC;Minified, the same query goes back to one line with the extra spaces taken out: SELECT u.id,u.email,COUNT(o.id) AS orders FROM users u LEFT JOIN orders o ON o.user_id = u.id WHERE u.created_at >= '2026-01-01' GROUP BY u.id,u.email ORDER BY orders DESC;
What the formatter does
- Puts each clause on its own line: SELECT, FROM, JOIN, WHERE, GROUP BY, ORDER BY and so on, with their contents indented underneath.
- Lists one column per line, which makes diffs in code review much easier to read.
- Indents subqueries and CTEs so nesting is visible.
- Sets keyword case to UPPER, lower or as you typed it. Data types (VARCHAR, INT) and functions (COUNT, SUM) follow the same choice.
- Leaves your data alone. String literals, quoted identifiers and comments are never changed.
- Handles many statements separated by semicolons, with a blank line between each.
Dialects
| Dialect | Things it understands |
|---|---|
| PostgreSQL | $$ strings, :: casts, ->> JSON operators, RETURNING |
| MySQL / MariaDB | `backtick` names, # comments, backslash escapes in strings |
| SQL Server (T-SQL) | [bracket] names, TOP, @variables, GO |
| SQLite | Its keywords and ? and :name parameters |
| BigQuery | `project.dataset.table` names, STRUCT and ARRAY types |
| Oracle PL/SQL | BEGIN … END blocks, :bind variables |
Snowflake, Redshift, DuckDB, ClickHouse, Spark, Hive, Trino and Db2 are in the list too. If yours isn’t, Standard SQL works for most everyday queries.
Minifying
Minify puts a query on one line, which is handy for logs, environment variables or pasting into code. Comments are taken out, except optimizer hints like /*+ INDEX(t idx) */ and MySQL’s /*! … */, which can change how the query runs. Strings keep their spaces exactly.
Common mistakes
- The wrong dialect. Backticks are names in MySQL but errors in PostgreSQL. If you see an error on a query that works, check the dialect first.
- Unclosed strings. An apostrophe inside a string must be doubled:
'it''s'. A single one starts a string that never ends. - Template placeholders. Placeholders like
{{ table }}from a templating tool may confuse the formatter. Replace them with a plain name, format, then put them back. - Treating “formats cleanly” as “correct”. The formatter checks structure, not whether your tables and columns exist.
Comparing two versions of a query? Use the text diff tool after formatting both the same way. Working with query results? The JSON formatter and JSON to CSV converter help with exports.
Questions people ask
Is my SQL sent anywhere?
Which dialect should I pick?
"col" in PostgreSQL, `col` in MySQL, [col] in SQL Server), in their keywords and in special syntax like PostgreSQL’s $$ strings or :: casts. If the formatter reports an error on SQL you know works, try the dialect again: that’s the usual cause.