About SQL Formatter
Paste a query copied from a log, an ORM or a one-line config value and get it back readable: SELECT, FROM, WHERE and JOIN each start a line, the columns and conditions under them are indented, and keywords are written in upper case, lower case or as you typed them.
Choose the dialect your database speaks, from PostgreSQL, MySQL, SQLite and SQL Server to BigQuery, Snowflake and Oracle, so its quoting, parameters and operators are understood. Switch to Minify to fold a query back onto one line.
How it works
- The query is read with the open-source sql-formatter library, using the grammar of the dialect you choose, and printed back with each clause on its own line.
- Keywords, data types and function names take the case you pick. Names, strings, numbers and comments are kept exactly as written.
- Minify mode uses a separate scanner that knows each dialect’s quoting and comment rules, so text inside strings and quoted names is never touched.
- Everything runs in a background worker in this tab, so a long script does not freeze the page and nothing is sent to a server.
Questions
Why does it say my query cannot be formatted?
The formatter met something it does not expect in the chosen dialect, and the message gives the line and column. Most often the dialect is wrong: @variables, [bracketed names] and backtick quotes, for example, are only understood by the dialects that use them.
Will formatting change what my query does?
No. Only whitespace and the letter case of keywords, types and functions change. Identifiers and string values are copied exactly. If your database treats unquoted names case-sensitively, choose "As written" for the keyword case.
Does it highlight syntax?
Not yet. The result is plain text that you can copy or download as a .sql file; paste it into your editor for colors.
How long a script can it take?
Up to 2 MB of SQL. Scripts with many statements are fine; a single statement that the parser cannot read stops the formatting with its position.
Everything you enter here is processed in this browser tab. Nothing is uploaded, logged or shared. How privacy works here.