SQL Formatter
Updated Free mock REST & WebSocket APIs
Paste a query to get it neatly formatted — one clause per line, indented joins and subqueries, consistent keyword case — or minify it to a single line. Choose your dialect so its syntax (::casts, backticks, [brackets], $1 parameters) is understood.
🔒 Runs in your browser — your queries are never uploaded.
How to format SQL
- Paste one or more SQL statements, or open a .sql file.
- Choose the dialect, keyword case (UPPER is the most common convention) and indentation.
- Copy the result or download it. Switch to Minify to strip comments and line breaks for embedding a query in code or a URL.
Before and after
select u.id, count(o.id) as orders from users u left join orders o on o.user_id = u.id where u.active = true group by u.id SELECT u.id, COUNT(o.id) AS orders FROM users u LEFT JOIN orders o ON o.user_id = u.id WHERE u.active = TRUE GROUP BY u.id
Which dialect should I choose?
| You use | Choose | Syntax it understands |
|---|---|---|
| PostgreSQL, Supabase, Neon | PostgreSQL | ::int casts, $1 params, $$ bodies, ILIKE |
| MySQL, PlanetScale | MySQL / MariaDB | `backticks`, # comments |
| SQL Server, Azure SQL | T-SQL | [brackets], @vars, TOP |
| Oracle | PL/SQL | :binds, q'[...]' strings |
| Warehouse SQL | BigQuery / Snowflake / Redshift | Their functions and identifiers |
If a query fails to format, the message shows where the parser stopped — the usual cause is a dialect-specific feature with Standard SQL selected.
Formatting doesn't change what the query does
Only whitespace and keyword case change; identifiers, string literals and comments are kept. Minify mode removes comments but keeps optimizer hints like /*+ INDEX(t idx) */.
Related tools
Frequently asked questions
Is my SQL uploaded anywhere?
No. The conversion runs entirely in your browser with JavaScript, so your SQL never leaves your device and isn't logged or stored.
Which SQL dialects are supported?
Standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, SQL Server (T-SQL), Oracle PL/SQL, BigQuery, Snowflake, Redshift, Spark, Trino/Presto, IBM Db2 and DuckDB.
Does it validate my SQL?
Not fully. The formatter tokenizes and parses enough to lay out the query and will stop on clear syntax errors, but it doesn't check table names or semantics — run the query against your database for that.
Can it format several statements at once?
Yes. Separate them with semicolons; each is formatted with a blank line between them.
Your business here? Sponsor this tool from $16/week. See placements