Skip to main content
dfmt · Ships April 2026

SQL formatting that understands SQL

Grammar-driven formatting for 15 SQL dialects. Native dbt and Jinja support. Keeps your line breaks where you put them. Fast enough for CI.
Built on the Datoria SQL Compiler, the same engine behind column lineage, type inference, and query optimization across 15 dialects.

15Dialects
11k files0 errors
~2s3,500 dbt models reformatted
f(f(x))=f(x)Idempotent
Comparison

How it compares

Benchmarked on 11,181 SQL files across 58 public dbt projects.

dfmtsqlfluffsqlfmt
SQL dialects15~111 (polyglot)
ParserFull grammar, 9,400+ typesANTLR-basedLexer-only
dbt / JinjaNative evaluatorRegex-basedBasic lexer
11k files benchmark34s, 0 errors6m 36s, crashed29s, 19 errors
IdempotentYesNoYes
Preserves user line breaksYes (preserveBreaks)NoNo
Configuration27 options + profiles100+ rules0 options
Comment preservationLosslessFragileGood
fmt:off / fmt:onYesYesNo
Principles

Six rules that govern every decision

Once you know these six rules, you can predict what the formatter will do without reading every option.

1

Clauses are the skeleton

Every SQL clause (SELECT, FROM, WHERE, GROUP BY, JOIN) starts on its own line. That structural rule is what makes a SQL file scannable, and the formatter never breaks it.

2

Short fits, long breaks

If a construct fits within the line width, it stays on one line. If it doesn't, it breaks vertically. Each construct decides on its own.

3

Your intent, preserved

With preserveBreaks on, the formatter treats your existing line breaks as signals. Write items flat, they stay flat. Write them vertical, they stay vertical. Each list decides on its own, and a formatted file formats back to itself.

4

Structure, not tokens

The formatter runs through a real grammar — over 9,400 AST types. It knows AND in WHERE is breakable, AND in BETWEEN is syntax, AND in CASE stays with its WHEN.

5

Every dialect, natively

15 SQL dialects from one shared grammar. Snowflake QUALIFY, BigQuery pipe syntax, T-SQL CROSS APPLY — formatted with the right defaults for each dialect.

6

Safe to adopt

Idempotent. Comments preserved. Lossless roundtripping. fmt:off/on for hand-tuned regions. You can roll it out one file at a time.

Get started

Format your dbt project in seconds.

# Format a dbt project
dfmt snowflake path/to/dbt/project --write

# Check formatting in CI (exits 1 if changes needed)
dfmt snowflake path/to/dbt/project --check

# Preview without writing
dfmt bigquery path/to/dbt/project

dfmt is the first product we shipped on top of the Datoria SQL Compiler, a closed-source engine covering 15 dialects with column lineage, type inference, and query optimization. The formatter is free. The full engine is in early access with a small number of partners. See what's under the hood →