{"id":4257,"library":"shandy-sqlfmt","title":"sqlfmt","description":"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.","status":"active","version":"0.29.0","language":"en","source_language":"en","source_url":"https://github.com/tconbeer/sqlfmt","tags":["sql","formatter","dbt","cli","code-quality"],"install":[{"cmd":"pip install shandy-sqlfmt","lang":"bash","label":"With pip"},{"cmd":"pipx install shandy-sqlfmt","lang":"bash","label":"Recommended with pipx"},{"cmd":"pipx install shandy-sqlfmt[jinjafmt]","lang":"bash","label":"With jinjafmt extra (includes black)"}],"dependencies":[{"reason":"Required for running the tool.","package":"python","version_constraint":">=3.10"}],"imports":[],"quickstart":{"code":"# To format all .sql and .sql.jinja files in the current directory and subdirectories:\nsqlfmt .\n\n# To see a diff of changes sqlfmt would make (without modifying files):\nsqlfmt --diff .\n\n# To format SQL from stdin and print to stdout:\necho \"select 1,2,3 from my_table where a=1\" | sqlfmt -","lang":"bash","description":"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`."},"warnings":[{"fix":"Upgrade your Python environment to version 3.10 or higher. For example, using pyenv or updating your system Python.","message":"sqlfmt now requires Python 3.10 or newer. Users on older Python versions will need to upgrade their environment.","severity":"breaking","affected_versions":"0.29.0+"},{"fix":"Always use sqlfmt within a version-controlled project (e.g., Git) and commit your changes before running the formatter. Review the diffs carefully before accepting them.","message":"sqlfmt is an alpha product and might not always produce the desired formatted output, or could potentially break SQL syntax. It is strongly recommended to run it on files in a version control system and commit changes before running sqlfmt.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Adjust any scripts or processes that consume `sqlfmt`'s stdout to account for the absence of the previously included extra trailing newline.","message":"When writing formatted code to stdout, sqlfmt no longer includes an extra trailing newline. This may affect scripts or tools that expect an additional newline when piping `sqlfmt` output.","severity":"breaking","affected_versions":"0.29.0+"},{"fix":"Understand that `sqlfmt` prioritizes consistency over customization. If its style does not align with your needs, consider alternatives or adapt your team to the `sqlfmt` style.","message":"sqlfmt is opinionated and not configurable beyond line length. It enforces a single style. If you require highly customizable formatting rules, sqlfmt may not be suitable.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}