WebTooli

SQL Formatter Online - Free SQL Beautifier & Minifier Tool

SQL Formatter for MySQL, PostgreSQL, SQL Server, SQLite, Oracle, and more. Beautify or minify SQL queries, customize indentation, keyword case, and dialect. All in your browser. Recent queries, shareable links, and dark mode. Free, private, no signup.

Recent: Your recent queries will appear here
1. Dialect and formatting
Each dialect has its own keywords and syntax rules.
Most style guides recommend uppercase keywords.
Affects how top-level clauses are indented.
Blank lines separating multiple statements.
Break long expressions when wider than this.
2. Input SQL
SQL input
4. Formatted output
Formatted SQL
ℹ️ Minify compresses SQL to a single line by removing comments and collapsing whitespace. String literals, quoted identifiers, and dialect-specific syntax are preserved exactly. Use it to embed queries in code, config files, or API payloads.
1. Options
Stripping produces the smallest output.
2. Input SQL
SQL input
3. Minified output
Minified SQL
ℹ️ Which dialect should I choose? The dialect controls which keywords are recognised and how certain syntax constructs are formatted. When in doubt, Standard SQL works for most queries.
MySQL Most popular
Default for WordPress, Laravel, and most shared hosting. Uses backtick identifiers (`table_name`), supports LIMIT offset, count syntax, and has its own set of string functions. Choose MySQL when working with a MySQL or MariaDB database.
PostgreSQL
PostgreSQL-specific features include ::type casts, RETURNING clauses, JSONB operators (->, ->>, #>), and window functions. Choose PostgreSQL when working with a PostgreSQL database or any derivative (Supabase, Neon, CockroachDB).
SQL Server (T-SQL)
Microsoft SQL Server uses [bracket] identifiers, TOP n instead of LIMIT, and GO batch separators. Choose T-SQL when working with SQL Server, Azure SQL, or Synapse.
Oracle (PL/SQL)
Oracle uses PL/SQL blocks, ROWNUM instead of LIMIT, and has distinctive data types like NUMBER and VARCHAR2. Choose PL/SQL when working with Oracle Database.
SQLite
SQLite is the embedded database used by mobile apps, browsers, and small applications. Its syntax is close to Standard SQL but has quirks around data types and dynamic typing. Choose SQLite for mobile, embedded, or desktop SQL.
BigQuery, Snowflake, Redshift, Spark, Hive
These are cloud data-warehouse dialects with distinctive syntax for handling nested records, arrays, and JSON. If you write SQL for a cloud warehouse, choose the matching dialect. The formatter knows their specific keywords and functions.
Which indent style should I use?
Standard means keywords align at the left margin and sub-clauses indent to the right. This is the layout used by most SQL style guides and by tools like DBeaver and pgAdmin.

Tabular left aligns top-level clauses at the left, with content left-aligned under each keyword.

Tabular right aligns top-level clauses at the left, with content right-aligned under each keyword. Both tabular styles are preferred by data engineers working with wide queries.
Keyword case. Uppercase or lowercase?
There is no universal rule. Uppercase keywords are the traditional convention and are recommended by most style guides, including Google's SQL style guide. Lowercase keywords are used by some teams for readability. What matters is consistency. Pick one and apply it across the entire codebase.
When to use Minify
Minified SQL is useful when embedding queries in application code, JSON API payloads, or configuration files where line breaks and comments are unnecessary. Do not minify SQL that will be read or edited by humans. The formatted version is far easier to maintain.
Does formatting change query behaviour?
No. SQL formatting is purely cosmetic. It changes whitespace and comments but never the meaning of the query. The database engine parses the SQL identically whether it is written on one line or one hundred. Formatting has zero effect on performance, results, or execution plans.
All formatting runs locally in your browser using the open-source sql-formatter library. No data is uploaded or stored.
Tip: press ⌘/Ctrl + Enter inside the SQL input to format.
⚠️ Sharing a link places your SQL in the URL. Avoid sharing production queries that contain sensitive table names or business logic.

A 50-line SQL query on one line is impossible to review

You know the query works. You tested it. Now you need to paste it into a pull request.

Nobody can read it. Joins wrap around the screen. The WHERE clause is a wall of AND conditions. The reviewer approves without reading.

Formatting fixes that. This tool beautifies SQL across 13 dialects in one click.

Formatting does not change how the query runs

SQL is whitespace-insensitive. The database engine parses SELECT * FROM users identically whether it is on one line or twenty.

Formatting is cosmetic. It changes indentation, line breaks, and keyword case. It never touches string literals, identifiers, or comments.

Zero effect on performance. Zero effect on results. Safe to format any query before running it.

13 dialects. One tool.

MySQL. PostgreSQL. SQL Server (T-SQL). SQLite. Oracle (PL/SQL). MariaDB. BigQuery. Snowflake. Redshift. Spark SQL. Hive. Db2. Standard SQL.

Each dialect has its own keywords and syntax rules. The formatter recognises them all. Choose the dialect that matches your database.

If you are unsure, Standard SQL is a safe default for everyday queries.

Beautify mode

Beautify expands compressed SQL into readable multi-line format. Each top-level clause starts on its own line at the left margin. SELECT, FROM, WHERE, GROUP BY, ORDER BY, HAVING, LIMIT.

Sub-clauses like JOIN and ON indent one level. AND and OR conditions wrap to their own lines so the logic is visible at a glance.

The formatter respects parentheses, string literals, quoted identifiers, and comments. It handles CASE WHEN blocks, window functions, CTEs, and dialect-specific syntax like PostgreSQL casts and MySQL backticks.

Minify mode

Minify compresses SQL to a single line. It removes comments and collapses whitespace runs.

String literals, quoted identifiers, and dialect-specific syntax stay exactly as written. The result is typically 30% to 70% smaller than the formatted version.

Use minified SQL when embedding queries in application code, JSON payloads, or config files. Do not minify SQL that humans will read or edit.

Formatting options

Keyword case. Uppercase, lowercase, or preserve. Uppercase is the traditional convention. Lowercase is popular in dbt projects.

Tab width. 2, 4, or 8 spaces per indent level.

Indent style. Standard, tabular left, or tabular right. Standard places clauses at the left with content indented. Tabular aligns top-level clauses and their content under each other.

Logical operator newline. Wrap AND and OR at the start of the line or at the end.

Lines between queries. How many blank lines separate multiple statements.

Expression width. The maximum width before long expressions break into multiple lines.

Recent queries and sharing

Every SQL you format or minify is saved to a recent list. Up to 10 entries. Click any chip to reload.

A Share button encodes the current query and dialect settings in the URL. Bookmark it or send it to a teammate. Opening the link restores the exact query and options.

Your dialect, keyword case, indent style, and other preferences are remembered across sessions on your device.

What this tool does not do

It does not validate SQL against a schema. It does not check for syntax errors beyond what the formatter can parse. It does not connect to any database.

It does not store your queries on a server. Everything runs in your browser. Nothing is uploaded, logged, or tracked.

The Share button places the query in the URL. If your SQL contains sensitive table names or business logic, do not share that link publicly.

Privacy and speed

All formatting uses the open-source sql-formatter library. It loads from a public CDN. Your query never leaves your device.

No signup. No account. No ads inside the tool.

Recent queries and preferences are saved in localStorage on your device. Clear your browser data and they are gone.

Frequently Asked Questions

How do I format SQL online?
Paste your query into the input area. Choose your SQL dialect from the dropdown. Click Beautify SQL. The formatted version appears immediately. You can adjust keyword case, tab width, indent style, and other options. The output updates when you change any setting. Press ⌘/Ctrl + Enter inside the input to format instantly.
Which SQL dialects are supported?
Thirteen dialects. Standard SQL (ANSI), MySQL, MariaDB, PostgreSQL, SQLite, SQL Server (T-SQL), Oracle (PL/SQL), BigQuery, Amazon Redshift, Snowflake, Apache Spark SQL, Apache Hive, and IBM Db2. Each dialect recognises its own keyword set and syntax rules, so the output is correct for the database you actually use.
Does formatting change how my query runs?
No. SQL formatting is purely cosmetic. It changes whitespace and comments but never the meaning of the query. The database engine parses the SQL identically whether it is one line or one hundred. Formatting has zero effect on performance, results, or execution plans. It is safe to format any query before running it.
← Back to all tools