shandy-sqlfmt
sqlfmt formats your dbt SQL files so you don't have to.
What it is and what it does
This package is a fast, opinionated SQL formatter built for dbt projects and other SQL codebases. It works by lexing SQL into tokens and reformatting to a single enforced style, without requiring a full SQL parser. This approach makes it much faster than traditional linters and easier to maintain. The tool formats select, delete, grant, revoke, and create function statements, preserves comments and some whitespace, and works with Jinja templates embedded in SQL.
It integrates with dbt, pre-commit, VSCode, and CI systems. Configuration is minimal—line length and dialect choice (polyglot by default, with special handling for ClickHouse). The package depends on click, jinja2, platformdirs, tomli, and tqdm for CLI, templating, configuration, and progress display.
Use it for:
- Enforce consistent SQL style across a dbt project without manual code review discussions
- Format SQL files automatically in pre-commit hooks or CI/CD pipelines before deployment
- Quickly reformat legacy or inconsistently-styled SQL codebases to a standard format
- Format Jinja-templated SQL files while preserving template logic
- Check SQL formatting compliance in CI without modifying files using --check mode
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A command-line SQL formatter that automatically reformats SQL files to a consistent style, similar to Black for Python or gofmt for Go.
Yes. The package is actively maintained, has no known vulnerabilities, low install friction, and fills a clear need for SQL formatting in dbt and analytics workflows. The Apache-2.0 license poses no restrictions. Start with a version-controlled repository and use --check or --diff on first run to verify output before committing changes.
Install
shandy-sqlfmt on PyPI
pip
pip install shandy-sqlfmtuv
uv add shandy-sqlfmtpoetry
poetry add shandy-sqlfmtInstalling shandy-sqlfmt
Before you install
Low install friction with a pure Python wheel and five lightweight runtime dependencies. Actively maintained with a release 4 days ago and steady repository activity.
License in practice
Licensed under Apache-2.0 (permissive), allowing use in commercial and private projects with minimal restrictions.
Quickstart
pip install "shandy-sqlfmt[jinjafmt]"
# Format SQL files in current directory
sqlfmt .
# Check formatting without modifying files
sqlfmt --check .
# Format from stdin
echo "select 1" | sqlfmt -
Requires Python 3.10 or above. The PyPI package name is shandy-sqlfmt, not sqlfmt.
Verify before relying
- Whether formatted output is always syntactically valid or if edge cases can break SQL
- Performance characteristics when formatting very large files or projects
- Completeness of support for SQL dialects beyond the documented ClickHouse special case
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — click, jinja2, platformdirs, tomli, tqdm |
| Maintenance | actively maintained — 4 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,415,027/month — #3,932 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: shandy_sqlfmt-0.32.0-py3-none-any.whl
Tags
More Quality Assurance packages
Coverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
ruffRuff is a Python linter and code formatter…
permissive · top 1,000 on PyPI
pexpectPexpect spawns and controls interactive console…
permissive · top 1,000 on PyPI
blackBlack reformats Python source code to a…
permissive · top 1,000 on PyPI
pytest-xdistpytest-xdist distributes pytest tests across…
permissive · top 1,000 on PyPI
cfn-lintValidates AWS CloudFormation templates in YAML…
permissive · top 1,000 on PyPI
collate-sqlfluffSQLFluff is a SQL linter and auto-fixer that…
permissive · top 15,000 on PyPI
sqlfluffSQLFluff is a SQL linter and auto-fixer that…
permissive · top 5,000 on PyPI
sqlfluff-templater-dbtEnables SQLFluff to lint and auto-fix dbt…
permissive · top 5,000 on PyPI
sqlglotSQLGlot parses, transpiles, optimizes, and…
permissive · top 1,000 on PyPI
sqlglotrsA SQL parser, transpiler, and optimizer that…
permissive · top 5,000 on PyPI
collate-sqllineageAnalyzes SQL statements to extract source and…
permissive · top 5,000 on PyPI
sqlfluffrsSQLFluff-rs is a Rust-based optional component…
permissive · top 15,000 on PyPI
acryl-sqlglotParses, transpiles, and optimizes SQL across 23…
permissive · top 15,000 on PyPI
sqlmeshSQLMesh is a data transformation framework that…
permissive · top 15,000 on PyPI
dbt-coredbt-core transforms raw data in a warehouse…
permissive · top 1,000 on PyPI