How it compares
Benchmarked on 11,181 SQL files across 58 public dbt projects.
| dfmt | sqlfluff | sqlfmt | |
|---|---|---|---|
| SQL dialects | 15 | ~11 | 1 (polyglot) |
| Parser | Full grammar, 9,400+ types | ANTLR-based | Lexer-only |
| dbt / Jinja | Native evaluator | Regex-based | Basic lexer |
| 11k files benchmark | 34s, 0 errors | 6m 36s, crashed | 29s, 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 |
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 9,400 AST types. It knows AND in WHERE is breakable, AND in BETWEEN is syntax, AND in CASE stays with its WHEN.
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.
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/projectdfmt 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 →