SQL Formatter
Format, beautify, and minify SQL queries with dialect support for MySQL, PostgreSQL, SQL Server, BigQuery, and more.
How to use SQL Formatter
-
Paste your SQL query
Paste your SQL query into the input panel on the left — a single statement or multiple statements separated by semicolons.
-
Select your SQL dialect
Choose the dialect that matches your database: MySQL, PostgreSQL, SQLite, SQL Server, Oracle, BigQuery, Snowflake, and more. Dialect selection affects keyword recognition and formatting rules.
-
Configure formatting options
Set indentation (2 spaces, 4 spaces, or tabs) and keyword casing (UPPERCASE, lowercase, or preserve original case) to match your team's style guide.
-
Format or minify
Click Format to beautify with indentation and casing, or Minify to compress the query to a single line for embedding in code or config files.
-
Copy the result
Click Copy to copy the formatted or minified SQL to your clipboard.
SQL Formatter FAQ
Which SQL dialects are supported?
Does formatting change the meaning of my SQL?
Is my SQL sent to a server?
Can I format multiple SQL statements at once?
What keyword casing options are available?
Can I minify SQL for use in code?
Does it support CTEs, window functions, and JSON operators?
Why does my formatted SQL look different from what my IDE produces?
Can I use this to format stored procedures?
Background
SQL Formatter transforms unreadable inline queries into clean, properly indented SQL using sql-formatter, a widely used open-source library that supports over a dozen SQL dialects with dialect-specific keyword handling and syntax rules.
Select your database dialect — MySQL, PostgreSQL, SQLite, SQL Server (T-SQL), Oracle PL/SQL, BigQuery, Snowflake, Redshift, Spark, Hive, Trino, MariaDB, or SingleStoreDB — and the formatter applies the right rules for your environment. Configure indentation width (2 or 4 spaces, or tabs) and keyword casing (uppercase, lowercase, or preserve) to match your team's SQL style guide.
The Minify mode strips all whitespace and compresses the query to a single line — useful for embedding SQL in application code, configuration files, or ORMs that build queries as strings.
Common uses: cleaning up queries exported from database admin tools, making raw ORM output readable for debugging, standardising SQL style across a codebase, and formatting queries before adding them to documentation. All formatting runs in your browser with no data sent to any server.
Related tools
JSON Formatter
Format, validate, and minify JSON instantly — with configurable indentation, error location, and tree view.
CSV to JSON Converter
Convert CSV to JSON or JSON to CSV instantly — paste data or upload a file with full delimiter and header control.
Diff Checker
Compare two texts, code files, or documents side by side — word-level diff highlighting, private and browser-based.
Regex Tester
Test regular expressions live with color-coded match highlighting, capture groups, replace mode, and common presets.