pgFormatter vs SQL Formatter
pgFormatter
github.comSQL Formatter
sql-formatter-org.github.ioSide by side
| Figure | pgFormatter | SQL Formatter |
|---|---|---|
| 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 | 8.2 (#6) | 7.7 (#13) |
| Editor integrations | The README describes use with Vim and (Neo)Vim and links to Atom and Visual Studio Code integrations. | The project lists VS Code and Vim extensions, a Prettier plugin, and an ESLint plugin integration. |
| Formatting options | Options include changing keyword, function, identifier, and type case; adjusting indentation; wrapping queries; and choosing comma placement. | Options include indentation, keyword and data type case, function and identifier case, logical operator placement, expression width, spacing between queries, and operator spacing. |
| Purpose | pgFormatter beautifies PostgreSQL SQL queries and PL/pgSQL code, and supports keywords from several SQL standards as well as PostgreSQL-specific keywords. | SQL Formatter is a JavaScript library for pretty-printing SQL queries. |
Plans
In their own words
pgFormatter
pgFormatter is free software for formatting PostgreSQL SQL queries and PL/pgSQL code. It supports SQL-92, SQL-99, SQL-2003, SQL-2008, SQL-2011 and PostgreSQL syntax, and the project says it also works with other databases. You can run it as a console program or CGI application that returns text or HTML; a CGI request with an application/json Accept header can return JSON. Formatting controls cover keyword, function, identifier and type case, indentation, query wrapping and comma placement. The --anonymize option hides query literals before formatting. The project documents source installation with Perl Makefile.PL, make and make install, Docker use, Vim and (Neo)Vim integration, Atom and Visual Studio Code links, and a pre-commit hook for SQL files. An online demo limits queries to ten thousand characters. It is distributed under the PostgreSQL Licence at free.
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.