// the find
tconbeer/sqlfmt
sqlfmt formats your dbt SQL files so you don't have to
sqlfmt is an opinionated, non-configurable SQL formatter built specifically for dbt projects. It works like black for Python — you don't negotiate with it about style, you just run it. It handles Jinja templating without needing to evaluate it, which is the core insight that makes it practical for dbt.
The lexer-not-parser approach is the right call: by not building a full AST, sqlfmt sidesteps the nightmare of supporting every SQL dialect's grammar while still producing consistent output. Jinja formatting is genuinely handled well — it formats the template source, not the rendered output, which means it actually works on real dbt codebases rather than just toy examples. The primer system (running sqlfmt against a corpus of real-world dbt repos and tracking the diff stats) is a solid way to catch regressions without writing exhaustive test cases for every edge case. Pre-commit and CI integration are first-class, which matters more than most formatter docs admit.
Only supports SELECT, DELETE, GRANT, REVOKE, and CREATE FUNCTION — if your dbt project has non-trivial DDL (CREATE TABLE, ALTER, indexes), sqlfmt silently passes on those files rather than formatting them. The ClickHouse dialect support is a half-measure: it disables lowercasing broadly, including common aggregate functions like sum and count, which is the wrong tradeoff. At 538 stars and 29 forks after years of being the formatter behind dbt Cloud's Format button, adoption signals suggest most teams either don't care about SQL formatting or are still hand-rolling sqlfluff configs. The 'no configuration' philosophy that makes it pleasant to adopt also makes it a non-starter for teams with existing style constraints they can't abandon.