SQL Formatter vs sqlfmt
SQL Formatter
sql-formatter-org.github.iosqlfmt
github.comSide by side
| Figure | SQL Formatter | sqlfmt |
|---|---|---|
| Price from | Free | Free |
| Free plan | Yes | Yes |
| Free trial | — | — |
| Open source | — | — |
| Web | Yes | Yes |
| Windows | Yes | — |
| macOS | Yes | — |
| Linux | Yes | Yes |
| API | — | Yes |
| Self-hosted | — | Yes |
| Plans published | 1 | 1 |
| Spec score · SQL Linters and Formatters | 7.7 (#13) | 8.5 (#3) |
| Editor integrations | The project lists VS Code and Vim extensions, a Prettier plugin, and an ESLint plugin integration. | The repository provides an Emacs sqlfmt-mode and a Vim ftplugin using formatprg and equalprg. |
| License | The software is released under the MIT license. | sqlfmt is distributed under the PostgreSQL Licence. |
| Purpose | SQL Formatter is a JavaScript library for pretty-printing SQL queries. | sqlfmt is a gofmt-style command-line formatter for PostgreSQL SQL. |
Plans
In their own words
SQL Formatter
SQL Formatter is a free, MIT-licensed JavaScript library for pretty-printing SQL queries, with a browser demo and command-line tool. Formatting options include indentation; keyword, data type, function, and identifier case; logical operator placement; expression width; query spacing; and operator spacing. It supports dialects including BigQuery, ClickHouse, DB2, DuckDB, Hive, MariaDB, MySQL, TiDB, Couchbase N1QL, Oracle PL/SQL, PostgreSQL, Redshift, SingleStoreDB, Snowflake, Spark, SQL Server Transact-SQL, and Trino/Presto. The command-line tool accepts SQL from standard input or a file, can produce formatted output, and can update a file in place. The project also lists VS Code and Vim extensions, a Prettier plugin, and an ESLint integration. Its JSON Schema supports configuration-file autocompletion and IntelliSense, with usage guides for VS Code and Zed. The library can replace prepared-statement placeholders when parameter values are supplied. It does not support stored procedures or changing the delimiter from a semicolon. Templating syntax is not directly supported; a parameter-type workaround may not cover every construct. The maintainer describes the project as being in maintenance mode, with feasible bug fixes and likely no new features.
sqlfmt
sqlfmt is a free formatter for PostgreSQL SQL, available as a command-line tool and as a browser formatter running through WebAssembly. Its river-aligned style pads clause keywords so they share a column. The CLI reads SQL from files or stdin and writes formatted SQL to stdout; it can also rewrite files in place, list files needing changes, and show unified diffs. Its explain subcommand formats PostgreSQL plan text and can provide advice, canonicalized output, or structural comparisons. Plan advice describes join order, join and access methods, and parallelism, without costs, row estimates, or timing. The explain diff operation returns exit code 0 for structurally identical plans and 1 when structures differ, so it can be used in scripts and CI. A Go subpackage provides formatting for Go programs, and the project includes Emacs and Vim integrations. The browser build exposes formatting and version functions to JavaScript. Deeply nested subqueries and less common upsert or DDL forms remain best-effort areas. sqlfmt is intended for standalone formatting and SQL used in The Art of PostgreSQL book and courses.