SQL formatter
Well formatted SQL makes reviews quicker and handovers easier.
PrivateNo uploadsRuns in your browserDialect is your database type; not sure? Keep Standard SQL. Keywords are words like SELECT and WHERE. Blank lines go between queries.

For the code review
Queries the whole team can read.
Code review. Akash's query reads clearly on the big screen.
BeforeLong queries nobody wants to read
With sdevClear lines anyone can review

Handover
A new teammate picks it up in minutes.

Lunch on time
The review ends early and lunch starts on time.
How to format SQL
Paste or open
Paste SQL into the Input pane, open a .sql file, or drop one on the pane. Sample loads a small shop's queries.
Pick dialect and style
Choose your database's dialect, keyword case, indent and blank lines between statements. Minify puts everything on one line instead. The output updates as you type.
Copy or download
Press Copy, or Ctrl+C (Cmd+C on Mac) with nothing selected, to copy the whole result. Download saves it as a .sql file.
Good to know
- Pick the dialect first: it decides how quotes, backticks, [brackets], $$ bodies and # comments are read.
- Keywords set to As typed leaves your capitalisation alone and only fixes layout.
- A parse error shows the line and column; Go to error selects that spot in the input.
- Minify strips comments and line breaks but keeps every string, quoted name and optimiser hint exactly as written.
- Everything runs in your browser. Nothing is uploaded.
Where people use it
Read a long query
Turn a query copied from logs into neat lines with one clause per line.
Clean up before a code review
Make keyword case and indents the same so others can follow the change.
Share in a chat or ticket
Paste a tidy query so your teammate can spot the problem fast.
Put a query on one line
Minify SQL to fit it into a config, a script or a string in code.
Why this one
It formats for your own database type, so special words and quotes stay correct, and nothing is sent to a server.
- Knows the rules of about 20 database types.
- Keyword case and indent the way you like.
- Your queries stay in your browser.
- No sign-up, works on phones.
What you can change
- Database type, like MySQL or PostgreSQL
- Keywords UPPER, lower or as typed
- Indent 2 spaces, 4 spaces or tab
- Beautify or minify
People find this page by searching
- sql formatter
- sql beautifier
- format sql online
- sql query formatter
- mysql formatter
- postgresql formatter
- sql server query formatter
- sql minify
- pretty print sql
Cite this tool
- APA
sdev.in. (n.d.). SQL formatter and beautifier online [Web tool]. https://www.sdev.in/tools/sql-formatter
- MLA
"SQL formatter and beautifier online." sdev.in, https://www.sdev.in/tools/sql-formatter.
- Chicago
sdev.in. "SQL formatter and beautifier online." https://www.sdev.in/tools/sql-formatter.
- BibTeX
@misc{sdev-sql-formatter, title = {SQL formatter and beautifier online}, author = {{sdev.in}}, howpublished = {\url{https://www.sdev.in/tools/sql-formatter}}, note = {Web tool} }
Questions people ask
Which SQL dialects are supported?
Standard SQL, MySQL, MariaDB, PostgreSQL, SQL Server (T-SQL), Oracle PL/SQL, SQLite, BigQuery, Snowflake, Redshift, Spark, Hive, Trino and Presto, DuckDB, ClickHouse, Db2, Db2 for IBM i, Couchbase N1QL, SingleStore and TiDB. Pick the one your query is written for so its quoting, operators and keywords are read correctly.
Why does it say it cannot parse my SQL?
The formatter reads the query with the rules of the chosen dialect. Backtick identifiers need MySQL or a similar dialect, [bracketed] names need SQL Server, and $$ bodies need PostgreSQL. The message names the line and column, and Go to error selects that spot. Minify never fails, because it only removes whitespace and comments.
Does formatting change what the query does?
No. Only whitespace, line breaks and the case of keywords change. Strings, quoted names and comments are kept as they are. Minify also drops comments, except MySQL /*! */ blocks and /*+ */ optimiser hints, which can change a plan.
Can I format a large dump?
Yes. Files over 2 MB stay out of the editor and a background worker reads them from disk, so the page stays responsive. Very large scripts take a few seconds; the first 1 MB of the result is shown and Download saves all of it.
Is my SQL uploaded?
No. Formatting runs in a web worker inside your browser with an open-source formatter. Nothing is sent to a server.