SQL Formatter
Format and lint SQL in any major dialect with sqlfluff, including auto-fix.
Install
irm https://raw.githubusercontent.com/chayprabs/localtools/main/sql-formatter/install.ps1 | iexlocaltools-sql-formatter updatelocaltools-sql-formatter uninstall
curl -fsSL https://raw.githubusercontent.com/chayprabs/localtools/main/sql-formatter/install.sh | bashlocaltools-sql-formatter updatelocaltools-sql-formatter uninstall
pipx install localtools-sql-formatterpipx upgrade localtools-sql-formatterpipx uninstall localtools-sql-formatter
Opens at http://127.0.0.1:47117 in your browser. Run localtools-sql-formatter --help for the command line. Set LOCALTOOLS_NO_OPEN=1 to install without opening it.
Direct download
| Platform | File | Size |
|---|---|---|
| Windows x64 | sql-formatter-1.0.2-windows-x64.zip | 23.0 MB |
| macOS Apple Silicon | sql-formatter-1.0.2-macos-arm64.zip | 30.2 MB |
| macOS Intel | sql-formatter-1.0.2-macos-x64.zip | 29.4 MB |
| Linux x64 | sql-formatter-1.0.2-linux-x64.zip | 41.8 MB |
SHA-256 checksums are in the release notes; the install scripts verify them for you.
See it
How to use
- Paste SQL or drop one or more .sql files.
- Pick the dialect (Postgres, MySQL, BigQuery, Snowflake, T-SQL, DuckDB and 22 more); optionally choose rules, a templater (Jinja or placeholders) or upload your .sqlfluff / pyproject.toml.
- Press Lint to see every violation with line, column, rule code and a link to the rule docs.
- Switch to Fix (or press Fix all) to get the fixed SQL with a diff; copy or download it.
- Use Transpile to convert a query between dialects, e.g. T-SQL to Postgres.
FAQ
Are the results the same as the sqlfluff CLI?
Yes. It runs sqlfluff 4 with your dialect and config, and the tests check that lint and fix output equal the sqlfluff CLI on TPC-H, dbt and GitLab SQL.
Can I use my existing .sqlfluff config?
Yes, upload .sqlfluff, setup.cfg, tox.ini or pyproject.toml. It is parsed, never executed: library paths, macro paths and the python/dbt templaters are ignored and listed.
Does it support dbt models?
Use the Jinja templater: it provides dbt's ref, source and config builtins, and fixes are applied to your template source. The full dbt templater (which needs a database connection) is not included.
How big can the SQL be?
The web UI takes up to 512 KB and about 2,000 statements per run, with a 120 second deadline because sqlfluff is thorough but slow. The command line has no limits.
Does my SQL leave my computer?
No. Everything runs locally on 127.0.0.1; there is no network access or telemetry.