Skip to main content

dfmt · Ships August 2026

It comes back whole.

Grammar-driven formatting for 43 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 engine behind column lineage, type inference, and query optimization.

Dialects

43

One grammar, formatted natively.

Files formatted

29 011

Across 164 public dbt projects.

Formatting errors

1

On the whole corpus, every run.

dbt models reformatted

26 888

Fast enough to run on every commit.

Comparison

How it compares

Benchmarked on 29,011 SQL files across 164 public dbt projects.

dfmtsqlfluffsqlfmt
SQL dialects43~111 (polyglot)
ParserFull grammar, 5,480 typesANTLR-basedLexer-only
dbt / JinjaNative evaluatorRegex-basedBasic lexer
29k+ files, whole corpus1 errorscrashed19 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.

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.

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.

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.

Structure, not tokens

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

Every dialect, natively

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

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 --dialect snowflake path/to/dbt/project --write

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

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

The engine · dquery

What's under the hood

dfmt is the first product we shipped on top of the Datoria SQL Compiler, a closed-source engine covering 43 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.