SQL Formatter
Turn one long unreadable query into indented SQL you can review — in your browser, with your query never leaving the tab.
The first format downloads a 79 KB SQL formatter from jsDelivr. Your query is never uploaded — it is formatted in this tab.
🔒 Runs entirely in your browser — nothing you type is uploaded or stored on a server.
Paste a query that arrived as one 400-character line and get back something you can actually read: clauses on their own lines, joins lined up, nesting indented. It handles 16 dialects — standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, SQL Server (T-SQL), Oracle (PL/SQL), BigQuery, Snowflake, Redshift, Spark, Hive, Db2, SingleStore, Trino and TiDB — because dialects disagree about enough syntax that a one-size formatter mangles half of them.
Also on Txtset: do the same for a JSON document · turn query results into JSON.
There is a reason to care where a SQL formatter runs. Real queries carry table names, column names and often literal values from production. Pasting those into a website means handing your schema to somebody else's server. Nothing you type here is uploaded. The first time you press Format, the page downloads the sql-formatter library (79 KB) from a CDN — pinned to version 15.6.9 and verified with Subresource Integrity — and from then on the work happens entirely in this tab, offline if you like.
Minify goes the other way: it strips -- and /* */ comments and collapses the query to a single line, which is what you want when a query has to live inside a config file or a shell command. The comment stripper is quote-aware, so a -- inside a string literal survives instead of eating the rest of your query.
One honest limit: this is a formatter, not a parser or a linter. It will lay out a query with a syntax error just as happily as a correct one, and it will not tell you the query is wrong. Run it against your database for that.
How to use
- Paste your SQL into the box.
- Pick the dialect you are writing for — it changes how quoting, functions and dialect-specific keywords are handled.
- Choose whether keywords should be uppercased, lowercased or left as typed, and pick an indent width.
- Press Format for readable SQL, or Minify for a single line with comments removed.
- Copy the result, or download it as a
.sqlfile.
Examples
select u.id,count(o.id) from users u left join orders o on o.user_id=u.id group by u.id comes back with each clause on its own line and the join indented under it.Set keywords to UPPERCASE and
select … from … where becomes SELECT … FROM … WHERE without touching your table or column names.SELECT 1 -- note minifies to SELECT 1, but SELECT '-- not a comment' keeps its string intact.Frequently asked questions
Is my query sent to a server?
Which dialects are supported?
Will it tell me if my SQL is invalid?
What exactly does Minify remove?
--, block comments between /* and */, and redundant whitespace. It is quote-aware: a comment marker inside a string literal is left alone rather than swallowing the rest of the query.