SQL Formatter
Format and beautify SQL queries with support for multiple dialects including PostgreSQL, MySQL, SQLite, and more.
How do I use SQL Formatter?
Paste your raw SQL query or stored procedure into the left editor, or click 'Load Sample' to load an analytical CTE query.
Select your database dialect (Standard SQL, PostgreSQL, MySQL, BigQuery, PL/SQL, or Snowflake), keyword casing, and indentation.
Copy the formatted SQL query or switch to 'Minify SQL' to collapse the query into a single line.
What features does SQL Formatter offer?
Format SQL queries instantly
Support for 8+ SQL dialects (PostgreSQL, MySQL, SQLite, T-SQL, MariaDB)
Configurable indentation (2 spaces, 4 spaces, tabs)
100% client-side local browser execution — zero server uploads
SQL Dialect Identifier Quoting, Parameter & Operator Matrix
Formatting SQL with the wrong dialect breaks database-specific operators (such as PostgreSQL `::` casts, BigQuery backtick project IDs, or Snowflake `=>` named parameters).
| SQL Dialect | Identifier Quote | Positional / Named Params | Dialect-Specific Operators |
|---|---|---|---|
| PostgreSQL | "table_name" | $1, $2 | :: type cast, ->, ->>, @>, ?| JSONB |
| MySQL / MariaDB | `table_name` | ?, :name | <=> NULL-safe equal, ->> JSON unquote |
| Google BigQuery | `project-id.ds.tbl` | @param, ? | UNNEST(), STRUCT<>, EXCEPT(), QUALIFY |
| Snowflake / Oracle | "TABLE_NAME" | :1, :bind_var | LATERAL FLATTEN(INPUT => x), :=, %TYPE |
Frequently Asked Questions about SQL Formatter
Why does formatting a PostgreSQL query in standard SQL mode break `::` type casts or JSONB operators?
Standard ANSI SQL does not include PostgreSQL's `::` cast or `@>`, `->`, `->>` JSONB operators, causing generic formatters to insert spaces inside the operator tokens. Selecting the `PostgreSQL` dialect keeps those multi-character operators atomic.
How do I format Google BigQuery table names that contain hyphens in the GCP project ID?
Select the `Google BigQuery` dialect (or open `/tools/bigquery-sql-formatter`). It recognizes backtick-quoted multi-part identifiers like `` `my-gcp-project.analytics.events` `` without splitting on the hyphen.
Does formatting or minifying a SQL query change its execution plan?
No. Relational database query planners parse SQL into an internal syntax tree and ignore whitespace and keyword casing outside of quoted string literals and identifiers.
Are my database table schemas or production queries uploaded to any server?
Never. The `sql-formatter` lexical tokenizer runs 100% locally in your browser's JavaScript engine.
Explore Related SQL Tools
PostgreSQL Query Formatter
Format and beautify PostgreSQL queries including WITH CTEs, JSONB operators (->>, @>), :: type casts, and window functions.
Oracle PL/SQL Formatter
Indent and beautify Oracle PL/SQL stored procedures, DECLARE...BEGIN...EXCEPTION...END blocks, packages, and %TYPE declarations.
BigQuery SQL Formatter
Format Google Cloud BigQuery Standard SQL queries with UNNEST(), STRUCT, ARRAY_AGG, EXCEPT, and backtick table identifiers.
Snowflake SQL Formatter
Format Snowflake Data Cloud SQL queries including LATERAL FLATTEN, VARIANT semi-structured paths (v:attr::string), and QUALIFY clauses.
JSON to SQL DDL & INSERT Statement Generator
Convert JSON objects or arrays into CREATE TABLE DDL schemas and INSERT INTO SQL statements for PostgreSQL, MySQL, SQLite, and SQL Server.
Database ER Diagram Builder
Design database schemas visually with drag-and-drop or DBML code. Export PostgreSQL, MySQL, and SQLite DDL scripts and download PNG/SVG diagrams. No account needed.