sqlfmt

0.29.0 · active · verified Sat Apr 11

sqlfmt is an opinionated Python-based command-line tool that automatically formats your dbt SQL files and other SQL statements. Similar to `black` for Python, it enforces a consistent style with minimal configuration, primarily line length. It is currently at version 0.29.0 and maintains an active release cadence with frequent updates.

Warnings

Install

Quickstart

sqlfmt is primarily a command-line tool. The most common usage is to format files in a directory. It will exit with a non-zero code if files are not formatted when using `--check` or `--diff`.

# To format all .sql and .sql.jinja files in the current directory and subdirectories:
sqlfmt .

# To see a diff of changes sqlfmt would make (without modifying files):
sqlfmt --diff .

# To format SQL from stdin and print to stdout:
echo "select 1,2,3 from my_table where a=1" | sqlfmt -

view raw JSON →