How SQL Formatter Works
Engineered for high-fidelity SQL formatting across 9+ database dialects with native AST parsers, side-by-side Git diff verification, and zero-retention formatting by default.
Core Architecture & AST Engine
Understanding why Abstract Syntax Tree parsing delivers superior reliability over regular expressions.
GoogleSQL & ZetaSQL AST
BigQuery queries are parsed using native GoogleSQL / ZetaSQL C++ engines. This supports complex GoogleSQL features including Pipe Syntax (|>), STRUCTs, ARRAYs, and procedural scripts without token corruption.
SQLFusion Rust Engine
PostgreSQL, MySQL, ClickHouse, Snowflake, DuckDB, SQLite, and ANSI queries are formatted using SQLFusion, a high-performance AST engine written in Rust built on Apache DataFusion sqlparser-rs that handles dialect-specific syntax quirks.
Microsoft ScriptDOM
SQL Server and T-SQL scripts are parsed with Microsoft ScriptDOM using the selected, versioned grammar. Typed AST nodes drive structured formatting, while the complete ScriptDOM generator provides a safe fallback for constructs the structured layout does not yet support.
Privacy-First Formatting
Enterprise-ready security boundaryWe understand that SQL queries often contain sensitive database schemas, proprietary business logic, and internal identifiers. Our system operates under strict privacy principles:
Internal formatter failures may offer an optional private bug report. Nothing is sent to the private tracker unless you review the editable query and explicitly consent to submit it.
Supported Dialects Breakdown
Engine support and key capabilities across all supported SQL dialects.
| Dialect | Engine | Key Capabilities |
|---|---|---|
| BigQuery (GoogleSQL) | GoogleSQL | Native GoogleSQL & ZetaSQL AST parsing engine · Full support for ARRAYs, STRUCTs, and UNNEST expressions · GoogleSQL Pipe Syntax (|>) support · Multi-statement procedural scripts & DDL formatting · Backtick-escaped project and dataset identifiers |
| PostgreSQL | SQLFusion | Recursive CTEs and Common Table Expressions · JSON and JSONB path extraction operators (->, ->>, #>) · Window functions with PARTITION BY and custom frame specifications · FILTER (WHERE ...) aggregation clauses · Dollar-quoted string literals and arrays |
| MySQL | SQLFusion | Backtick identifier escaping (`table`.`column`) · HAVING and GROUP BY clauses with aggregate filters · String and date functions (DATE_FORMAT, COALESCE, IFNULL) · INNER, LEFT, RIGHT, and FULL OUTER JOIN indentation |
| SQL Server (T-SQL) | ScriptDOM | Microsoft ScriptDOM parser and generator with versioned T-SQL grammars · Square bracket identifier escaping ([dbo].[TableName]) · TOP (N) and OFFSET-FETCH pagination clauses · CROSS APPLY and OUTER APPLY joins · Common Table Expressions (WITH CTE) |
| ClickHouse | SQLFusion | ClickHouse PREWHERE and WHERE clauses · Nested aggregation combinators (-State, -Merge, -ExactWeighted) · Array manipulation and lambda functions · DateTime functions and interval expressions |
| Snowflake | SQLFusion | Snowflake colon type casting (::type) · Semi-structured JSON path queries and FLATTEN · Stage references and warehouse commands · Window functions and analytical clauses |
| DuckDB | SQLFusion | DuckDB parquet, JSON, and CSV reader functions · List and struct transformations · QUALIFY clauses and regex matching · Positional reference and columns expression |
| SQLite | SQLFusion | Standard SQLite queries and PRAGMA statements · JSON functions (json_extract, ->, ->>) · CTE and window function support · Transactions and savepoints |
| Oracle SQL | SQLFusion | Oracle JSON_TABLE and JSON path queries · Hierarchical queries (START WITH ... CONNECT BY PRIOR) · Analytical window functions with custom framing · Quote-delimited string literals (q'[...]') · ROWNUM and FETCH FIRST ... ROWS ONLY pagination |
| Databricks SQL | SQLFusion | Delta Lake time travel (TIMESTAMP AS OF / VERSION AS OF) · Colon JSON and struct field access (payload:field.subfield) · STRUCT and ARRAY literal expressions · LATERAL VIEW EXPLODE / INLINE clauses · Backtick catalog, schema, and table identifiers |
| SparkSQL | SQLFusion | Apache Spark SQL syntax and function support · LATERAL VIEW and Table-Valued Generator Functions (EXPLODE, INLINE) · Struct field navigation and backtick identifiers · CACHE TABLE and UNCACHE TABLE DDL commands · DIV arithmetic integer division operator |
| Apache Hive | SQLFusion | HiveQL LATERAL VIEW and EXPLODE expressions · CLUSTER BY, DISTRIBUTE BY, and SORT BY clauses · Partitioned table queries · Complex type constructors (ARRAY, MAP, STRUCT) |
| Amazon Redshift | SQLFusion | Amazon Redshift date and time functions (DATEADD, DATEDIFF) · Window aggregations and analytical framing · VACUUM, UNLOAD, and COPY statements · Column encoding and distribution keys |
| Generic / ANSI SQL | SQLFusion | Standard ANSI SQL:1999/2011 compliant formatting · Common Table Expressions (WITH clauses) · Standard JOINs (INNER, LEFT, RIGHT, FULL OUTER) · Window functions and aggregate subqueries |
Frequently Asked Questions
Answers to common questions regarding formatting, dialect behavior, and features.
What makes this formatter different from traditional online SQL formatters?
Which parsing engines power the formatters?
Is my SQL query saved, logged, or retained on your servers?
Does the formatter support multi-statement SQL scripts?
always_break_query).How does the side-by-side Git diff viewer work?
Does the formatter support GoogleSQL Pipe Syntax (|>)?
|> WHERE, |> AGGREGATE, |> EXTEND, |> SET, |> JOIN, and |> WINDOW with custom pipe breaking rules.What happens if my query contains syntax errors?
Is there an API available for programmatic formatting or CI/CD pipelines?
Ready to format your queries?
Try our instant multi-dialect formatter with live diff inspection and custom formatting rules.
Open SQL Formatter