Installation
Want to test out sqlfmt on a query before you install it? On the homepage is an interactive playground with the latest sqlfmt version.
Recommended Installation: Use uv
sqlfmt is a command-line tool that is built in Python and runs on MacOS, Linux, and Windows. It is distributed
on PyPI under the name shandy-sqlfmt
. There are many ways to install and run it, but we strongly
recommend using uv:
-
Install uv. From a POSIX shell, run:
curl -LsSf https://astral.sh/uv/install.sh | sh
Or using Windows Powershell:
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
-
Install sqlfmt as a tool using uv:
uv tool install "shandy-sqlfmt[jinjafmt]"
This command will install sqlfmt into an isolated environment and add it to your PATH so you can easily run the executable.
tipDepending on your shell and OS, you may need single or double quotes around
shandy-sqlfmt[jinjafmt]
. -
Test the installation; run sqlfmt with no arguments:
sqlfmt
You should see some ASCII art and help text.
The PyPI distribtuion is shandy-sqlfmt
, NOT sqlfmt
, which is a different (unrelated but not malicious) package.
This is unfortunate, but the author cannot do anything about it.
Other Installation Options
Use pip or something pip-like:
If you know what you’re doing, after installing Python 3.9 or above and activating your virtual environment, install shandy-sqlfmt
using pip, pipx, poetry, or any other program that can install Python packages from PyPI:
pip install "shandy-sqlfmt[jinjafmt]"
Use Docker
You can skip installation altogether and pull the official Docker image instead. See the docs on running sqlfmt in a container.