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.
`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.
::type casts, RETURNING clauses, JSONB operators (->, ->>, #>), and window functions. Choose PostgreSQL when working with a PostgreSQL database or any derivative (Supabase, Neon, CockroachDB).
[bracket] identifiers, TOP n instead of LIMIT, and GO batch separators. Choose T-SQL when working with SQL Server, Azure SQL, or Synapse.
ROWNUM instead of LIMIT, and has distinctive data types like NUMBER and VARCHAR2. Choose PL/SQL when working with Oracle Database.
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.
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.