Want to test out sqlfmt on a query before you install it? Go to sqlfmt.com to use the interactive, web-based version.
📄️ Using sqlfmt
sqlfmt will not always produce the formatted output you might want. It might even break your SQL syntax. It is highly recommended to only run sqlfmt on files in a version control system (like git), so that it is easy for you to revert any changes made by sqlfmt. On your first run, be sure to make a commit before running sqlfmt.
📄️ Configuring sqlfmt
You probably don't need to configure sqlfmt at all! sqlfmt supports nearly all SQL dialects without configuration, and doesn't require a Jinja templater.
📄️ Disabling sqlfmt
If you would like sqlfmt to ignore a file, or part of a file, you can add -- fmt on comments to your code (or # fmt off at the top of a file will keep the entire file intact.
📄️ Formatting Jinja
sqlfmt loves properly-formatted Jinja, too.
📄️ Using sqlfmt in a Container
We build official container images with every release of sqlfmt (since v0.15.0) and push them to GHCR (the GitHub Container Registry). With Docker installed, you can run sqlfmt to format all files in your current working directory with:
📄️ Improving Git Blame
When running sqlfmt for the first time, or when running an upgraded version of sqlfmt after a style change, you are likely to produce a large number of changes in your codebase.
📄️ About File Encodings
You probably don't have to worry about this.