Skip to content
SPECIFICTION
Get listed

pgFormatter

github.com

Free plan WebLinuxAPISelf-hosted
Visit github.com
Spec score 8.2 #6 of 26 in SQL Linters and Formatters

What it is

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.

Spec sheet

Purpose
pgFormatter beautifies PostgreSQL SQL queries and PL/pgSQL code, and supports keywords from several SQL standards as well as PostgreSQL-specific keywords.Read 30 Sep 2026 · github.com
Anonymization
The command line option --anonymize obscures query literals before formatting.Read 30 Sep 2026 · github.com
Docker
The project documents building a Docker image and piping SQL input to a container running pgFormatter.Read 30 Sep 2026 · github.com
Editor integrations
The README describes use with Vim and (Neo)Vim and links to Atom and Visual Studio Code integrations.Read 30 Sep 2026 · github.com
Formatting options
Options include changing keyword, function, identifier, and type case; adjusting indentation; wrapping queries; and choosing comma placement.Read 30 Sep 2026 · github.com
Installation
The README documents installation from a GitHub source tarball using Perl Makefile.PL, make, and make install.Read 30 Sep 2026 · github.com
JSON API
When called as a CGI application with an Accept: application/json header, pgFormatter can return a JSON response; the API can be disabled in its CGI configuration.Read 30 Sep 2026 · github.com
Maker and license
The README credits Gilles Darold as the original author and says pgFormatter is free software distributed under the PostgreSQL Licence.Read 30 Sep 2026 · github.com
Online demo limit
The README describes an online demo that limits SQL queries to ten thousand characters.Read 30 Sep 2026 · github.com
Other databases
The project says pgFormatter also works with other databases.Read 30 Sep 2026 · github.com
Pre-commit integration
The README documents configuring pgFormatter as a pre-commit hook for SQL files.Read 30 Sep 2026 · github.com
Security and privacy
The anonymization option is described as useful for hiding confidential data before formatting; the repository page opened did not state security certifications or compliance claims.Read 30 Sep 2026 · github.com
Support and limits
The README notes that pgFormatter cannot detect user-defined functions or keywords for other databases automatically, but allows custom lists for them.Read 30 Sep 2026 · github.com
Ways to run
It can run as a console program or a CGI application, producing text or HTML based on its environment.Read 30 Sep 2026 · github.com

Plans and prices

pgFormatter Free Free software distributed under the PostgreSQL Licence Read 30 Sep 2026 · github.com

Every pgFormatter plan and price →

Strong points and limits

Strong points

  • Supports multiple SQL standards and PostgreSQL
  • Runs as console or CGI application
  • Offers configurable case, indentation and wrapping
  • Can anonymize query literals
  • Integrates with editors and pre-commit hooks

Limits

  • Online demo limits queries to 10,000 characters
  • Cannot automatically detect custom functions or other-database keywords
  • CGI JSON API can be disabled

Who it suits

pgFormatter suits developers and database teams working with PostgreSQL or other SQL databases. Its console, CGI, Docker, editor and pre-commit options support different development workflows.

Verdict

pgFormatter provides broad SQL formatting controls with command-line, web, editor and CI/CD paths. Users of other databases may need to maintain custom function and keyword lists.

Where Specifiction places it

Alternatives to pgFormatterAll alternatives →