Comparison
How it compares
Benchmarked on 29,011 SQL files across 164 public dbt projects.
| dfmt | sqlfluff | sqlfmt | |
|---|---|---|---|
| SQL dialects | 43 | ~11 | 1 (polyglot) |
| Parser | Full grammar, 5,480 types | ANTLR-based | Lexer-only |
| dbt / Jinja | Native evaluator | Regex-based | Basic lexer |
| 29k+ files, whole corpus | 1 errors | crashed | 19 errors |
| Idempotent | Yes | No | Yes |
| Preserves user line breaks | Yes (preserveBreaks) | No | No |
| Configuration | 27 options + profiles | 100+ rules | 0 options |
| Comment preservation | Lossless | Fragile | Good |
| fmt:off / fmt:on | Yes | Yes | No |
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/projectThe 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.