SQL Formatter
Paste a query to instantly reformat it with consistent indentation and keyword casing. Pick your database dialect for the most accurate result.
Why use an online SQL formatter?
SQL pasted from a log, an ORM's debug output, or a single-line export is hard to read and easy to misread — a misplaced JOIN condition or WHERE clause can hide in a wall of text. This formatter reformats your query with one clause per line, consistent indentation, and a keyword case of your choice, so the structure is obvious at a glance.
Everything runs in your browser, so queries with real table or column names never leave your machine. There is no sign-up and no limit on how often you use it.
Example: before and after
A one-line query copied from an application log:
select o.id,c.name,sum(i.qty*i.price) total from orders o join customers c on c.id=o.customer_id left join order_items i on i.order_id=o.id where o.created_at>='2026-01-01' group by o.id,c.name having sum(i.qty*i.price)>100 order by total descThe same query after formatting with uppercase keywords:
SELECT
o.id,
c.name,
sum(i.qty * i.price) total
FROM
orders o
JOIN customers c ON c.id = o.customer_id
LEFT JOIN order_items i ON i.order_id = o.id
WHERE
o.created_at >= '2026-01-01'
GROUP BY
o.id,
c.name
HAVING
sum(i.qty * i.price) > 100
ORDER BY
total DESCEach clause now starts on its own line, the joins line up under FROM, and the HAVING filter is no longer buried in the middle of the GROUP BY.
Supported SQL dialects
- Standard SQL — fine for ordinary SELECT/INSERT/UPDATE/JOIN queries on any database.
- MySQL and SQLite — backtick identifiers, LIMIT, and MySQL-specific functions.
- PostgreSQL — :: casts, RETURNING, dollar-quoted strings and JSON operators.
- SQL Server (T-SQL) — TOP, square-bracket identifiers, variables like @id and GO separators.
- Oracle (PL/SQL) — DECLARE/BEGIN/END blocks, := assignments, and Oracle keywords.
- BigQuery and Snowflake — backtick-quoted project.dataset.table names, QUALIFY and other warehouse syntax.
How to format SQL
- Paste your query into the input box.
- Choose the dialect of the database you run it on.
- Choose the keyword case you prefer.
- Click Format, then Copy to paste it back into your editor.
Frequently asked questions
- Will this change what my query does?
- No — only whitespace, line breaks, and keyword casing are changed. The query logic and output are identical.
- Which SQL dialect should I pick?
- Pick the database you're actually running the query against. Dialects mostly affect formatting of dialect-specific syntax (like T-SQL's TOP or PL/SQL blocks) — Standard SQL works fine for typical SELECT/JOIN/WHERE queries.
- Can it format several statements at once?
- Yes. Paste a whole script with statements separated by semicolons and each statement is formatted separately.
- Is my SQL sent to a server?
- No. Formatting happens entirely in your browser with JavaScript, so your queries, table names and data never leave your computer.
- Does it validate my SQL?
- It's a formatter, not a full SQL parser/validator — badly malformed SQL may format oddly or throw an error, but this isn't a substitute for actually running the query against your database.