Free Online SQL Query Formatter, Beautifier & Minifier
A generic formatter breaks the moment your SQL stops being generic - one PostgreSQL :: cast or T-SQL [bracketed] identifier is enough to fail the parse. This SQL query formatter reads your dialect instead: pick from 20, including PostgreSQL, MySQL, SQL Server, BigQuery and Snowflake, then beautify with your keyword case and indent width, or minify without touching string literals. Paste a query or upload a file - free, no signup.
SQL Formatter & Beautifier Online
Paste a query and it is laid out as you type - one clause per line, consistent indentation, and keywords cased the way you set them. Set the indent width and keyword case in the editor’s control strip; everything runs in your browser, so the query never leaves your machine.
Pasted in
select u.id,u.name,o.total
from users u join orders o on o.user_id=u.id
where o.total>100 order by o.total descFormatted out
SELECT
u.id,
u.name,
o.total
FROM
users u
JOIN orders o ON o.user_id = u.id
WHERE
o.total > 100
ORDER BY
o.total DESCPick a Dialect: T-SQL, PostgreSQL, and 18 More
Every database bends SQL its own way, and a parser working under generic rules fails on exactly those lines. Standard SQL is the default and handles ordinary queries; anything vendor-specific needs the matching dialect. These are the ones people reach for most.
| Dialect | What it changes | Syntax it unlocks |
|---|---|---|
| Standard SQL | The default. Plain ANSI SQL, no vendor extensions. | — |
| PostgreSQL | Casts, JSON operators, dollar-quoted blocks | x::int, data->>'k', $$body$$ |
| SQL Server (T-SQL) | Bracketed identifiers | [dbo].[My Col] |
| MySQL / MariaDB | Backtick identifiers, # comments, backslash escapes | `my col`, # note |
| BigQuery | Backtick identifiers, # comments, backslash escapes | `project.dataset.table` |
| SQLite / DuckDB | Backtick identifiers | `my col` |
| Amazon Redshift | Dollar-quoted blocks | $$body$$ |
Also available: Snowflake, Oracle PL/SQL, Apache Hive, Apache Spark, Trino, ClickHouse, IBM Db2, IBM Db2 for i, N1QL (Couchbase), TiDB and SingleStoreDB - 20 in total. If a query will not parse, switching from Standard SQL to your database’s dialect is the fix for the most common failure.
Minify SQL Query
Minify compacts the query onto one line: comments go, and runs of whitespace become single spaces. It reads the query rather than pattern-matching it, so text inside string literals is copied through exactly as written - punctuation and spacing included.
Pasted in
SELECT id, note, city -- keep this row readable
FROM places
WHERE note = 'a--b' AND city = 'Paris, France';Minified out
SELECT id, note, city FROM places WHERE note = 'a--b' AND city = 'Paris, France';The trailing comment is gone, but the two dashes inside a--b and the spacing inside Paris, France both survive - a regex pass over the same query would have truncated the first value and rewritten the second.
How to Format or Minify SQL
- Paste your SQL into the input box, or upload a .sql file from your computer.
- Pick your dialect if the query uses vendor syntax - PostgreSQL for casts and JSON operators, SQL Server for bracketed identifiers, MySQL for backticks. Standard SQL is the default and handles ordinary queries.
- The query is formatted as soon as you type, so there is usually nothing to click. Change the indent width or keyword case and it reformats; the "Format SQL" button reformats on demand.
- Press "Minify SQL" to compact the query onto one line, or "Remove Comments" to strip comments from the input while leaving the layout alone.
- If a query cannot be parsed, the output pane says so and the failing line is marked in the input. Choosing the right dialect fixes most of these.
- Copy the result, or download it as a .sql file for your project.