SQL Formatter & Minifier
Beautify or minify SQL with real per-dialect tokenization for Postgres, MySQL, T-SQL, BigQuery, Snowflake, and more.
Your SQL is formatted in your browser and never uploaded.
About SQL Formatter & Minifier
SQL turns up unformatted constantly: a one-liner copied from an ORM query log, a BI export, a code review, or a WHERE clause someone flattened to paste into Slack. This tool beautifies it into readable, consistently indented SQL, or minifies it by stripping unnecessary whitespace so the query takes the fewest bytes for a config string or embedded query. The dialect selector changes how the SQL is tokenized, so PostgreSQL, MySQL, MariaDB, SQL Server (T-SQL), BigQuery, SQLite, Snowflake, Spark SQL, and standard SQL each parse on their own rules instead of a one-size-fits-all guess. You can set keyword case to upper, lower, or preserve, choose an indent width of a tab or 2 or 4 spaces, and in minify mode read a before/after byte count to see how much smaller the query got. The output appears on the right as you type, so there is no submit button to press. Privacy is built into how it works: SQL often carries schema names, literal data, and sometimes credentials, and every operation runs in the browser with no network call, so the query never leaves the machine. Minify keeps each line comment on its own line so it never comments out the rest of the query, which means a minified query with line comments can span more than one line. Formatting only changes whitespace and casing, not what the query does, so the result runs identically to what you pasted.
How to use the SQL Formatter & Minifier
- Paste your SQL into the input box, or drop a .sql file onto it.
- Choose a mode: Beautify for readable multi-line SQL, or Minify to strip unnecessary whitespace and shrink the query.
- Pick the dialect that matches your database so the query tokenizes correctly.
- Set keyword case (upper, lower, or preserve) and, in Beautify, the indent width.
- The formatted output appears on the right as you type; there is no submit button.
- In Minify mode, check the before/after byte count to see how much smaller it got.
- Copy the result, or clear the box to start over.
Common Use Cases
Read an ugly ORM log query
Beautify a one-line query pulled from a query log so you can actually read the joins and conditions during debugging.
Embed a query in code or config
Minify a multi-line query to strip its whitespace for a JSON or YAML config value or an inline string, with the byte count to confirm the size.
Standardize style across a dialect
Apply uppercase keywords and a fixed indent so a Postgres or BigQuery query matches your team's house style before committing.
Format safely with sensitive data
Tidy a query that contains schema names, literal customer data, or a connection string without sending it to a server.
Frequently Asked Questions
Is it safe to paste SQL into this formatter?
Yes. Every operation runs in your browser with no network calls, so your query is never uploaded. You can paste SQL containing schema names, literal data, or credentials and it stays on your machine.
What is the difference between beautifying and minifying SQL?
Beautifying adds line breaks and indentation to make the query readable. Minifying strips unnecessary whitespace and newlines to minimize the query's size for embedding in code or config. It keeps each line comment on its own line so the comment does not swallow the rest of the query, so a minified query with line comments can span more than one line. Both only change whitespace and casing, not what the query does.
Can I format SQL for a specific database dialect?
Yes. Choose from PostgreSQL, MySQL, MariaDB, SQL Server (T-SQL), BigQuery, SQLite, Snowflake, Spark SQL, or standard SQL. The dialect changes how the query is tokenized, so dialect-specific syntax formats correctly.
How do I make SQL keywords uppercase?
Set keyword case to Upper and every keyword like select, from, and where is rewritten in uppercase. Lower does the opposite, and Preserve leaves your casing as typed.
Does formatting change what my query does?
No. Formatting and minifying only adjust whitespace and keyword casing. The tokens, table names, string literals, and logic are unchanged, so the query runs identically.
Why won't my SQL format?
Usually the dialect does not match (for example, T-SQL-only syntax under the PostgreSQL setting) or there is a genuine syntax error the parser cannot read. Try switching the dialect; if it still fails, the message points you to check the query.