WebTooli
Advertisement
750 × 90

SQL Formatter Online — Beautify, Minify & Format SQL Queries Online

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.

v2
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 are writing SQL for a cloud warehouse, choose the matching dialect — the formatter knows their specific keywords and functions.
Which indent style should I use?
Standard — keywords align at the left margin, 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 — top-level clauses align at the left, and the content is left-aligned under each keyword.

Tabular right — top-level clauses align at the left, and the content is 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 the one used by 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.

SQL Formatter: Beautify, Minify & Format SQL Queries Online

SQL Formatter is a browser-based tool for beautifying and minifying SQL queries across every major dialect. Paste a query, choose your dialect, and get clean, consistently indented SQL in one click — or compress it to a single line for embedding in application code. The tool supports MySQL, PostgreSQL, SQL Server (T-SQL), SQLite, Oracle (PL/SQL), MariaDB, BigQuery, Snowflake, Redshift, Spark SQL, Hive, and IBM Db2. All formatting runs locally in your browser; nothing is uploaded, logged, or stored.

The formatter uses the same open-source library that powers database IDEs and command-line tools, so the output matches the style conventions used by professional SQL developers. You can control keyword case, indentation, tab width, indent style, and how logical operators are wrapped — and see the result update in real time.

Why Format SQL?

SQL is whitespace-insensitive — the database engine parses SELECT * FROM users WHERE id = 1 identically whether it is written on one line or twenty. But human readability is a different matter. A well-formatted query makes code review easier, simplifies debugging, enforces team consistency, and preserves the intent behind complex logic through comments.

Beautify Mode

Beautify expands a compressed SQL query into a readable multi-line format. Each top-level clause — SELECT, FROM, WHERE, GROUP BY, ORDER BY, HAVING, LIMIT — begins on its own line at the left margin. Sub-clauses like JOIN and ON indent one level. AND and OR conditions in WHERE clauses 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 edge cases like CASE WHEN ... THEN ... ELSE ... END blocks, window functions (RANK() OVER (PARTITION BY ... ORDER BY ...)), CTEs (WITH ... AS (...)), and dialect-specific syntax such as PostgreSQL's :: casts and MySQL's backtick identifiers.

Minify Mode

Minify compresses SQL to a single line by removing comments and collapsing whitespace runs. String literals, quoted identifiers, and dialect-specific syntax are preserved exactly. The result is typically 30–70% smaller than the formatted version, depending on how many comments and blank lines the original contained. Minified SQL is useful when embedding queries in application code, JSON API payloads, configuration files, or URLs.

Dialect Support

Each SQL dialect has its own keyword set, syntax quirks, and style conventions. The formatter includes dedicated support for thirteen dialects, including MySQL, MariaDB, PostgreSQL, SQLite, SQL Server (T-SQL), Oracle (PL/SQL), BigQuery, Redshift, Snowflake, Spark SQL, Hive, and IBM Db2. When you change the dialect, the formatter recognises that dialect's keywords and applies the correct formatting rules.

Formatting Options

Keyword case — uppercase, lowercase, or preserve as-is. Tab width — 2, 4, or 8 spaces per indent level. Indent style — standard (clauses at left, content indented) or tabular (top-level clauses and their content aligned under each other). Logical operator newline — wrap AND / OR at the beginning 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 are broken into multiple lines.

Recent Queries, Sharing, and Persistence

Every SQL you format or minify is saved to a recent-items list — up to 10 entries, clickable to reload. A Share button encodes the current query and dialect settings in the URL, so you can bookmark or send it to a teammate. Your dialect, keyword case, indent style, and other options are remembered across sessions on your device.

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. It is safe to format any query before running it.

Private, Fast, and Free

All formatting runs locally in your browser using the open-source sql-formatter library. No query, no schema, and no data is transmitted to a server. There is no sign-up, no rate limit, and no watermark. Recent queries and preferences are stored in your device's local storage only.

Frequently Asked Questions

How do I format SQL online?
Paste your query into the input area, choose your SQL dialect from the dropdown, then click Beautify SQL. The formatted version appears in the output area immediately. You can adjust keyword case, tab width, indent style, and other options — the output updates automatically 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.
Kya yeh SQL formatter free hai?
Ji haan, yeh tool 100% free hai. Koi signup, watermark ya payment ki zaroorat nahi. Aap jitni baar chahein SQL queries ko beautify ya minify kar sakte hain — 13 dialects supported hain.
Kya mera data kahin upload hota hai?
Nahi. Saari formatting aap ke browser mein open-source sql-formatter library ke zariye hoti hai. Aap ki queries kisi bhi server par nahi bheji jati. Recent queries aur preferences sirf aap ke device par localStorage mein save hote hain. Note: "Share" button se aap khud query ko URL mein encode kar sakte hain — uss link ko sensitive data ke saath share na karein.
Beautify aur Minify mein kya farq hai?
Beautify compressed SQL ko readable multi-line format mein expand karta hai — har clause apni line par, proper indentation ke saath. Minify SQL ko single line mein compress karta hai — comments remove karke aur whitespace collapse karke. Minified SQL typically 30–70% chhota hota hai. Use Beautify jab aap query ko review karna chahein; Minify jab aap query ko code, JSON payload, ya config mein embed karna chahein.
← Back to all tools
Advertisement
750 × 90

WebTooli — Free Online Tools & Web Utilities

A curated collection of free web tools to boost your productivity — organized by category, running entirely in your browser.

Image Tools

Advertisement
750 × 90

PDF Tools

Text Tools

Advertisement
750 × 90

SEO Tools

Calculator Tools

Converter Tools

Advertisement
750 × 90

Developer Tools

Other Tools