FREEDOM251

Freedom251 › SQL Linters and Formatters

pgFormatter

Free plan APILinuxSelf-hostedWeb

Visit pgFormatter Alternatives Pricing

pgFormatter's own site

What pgFormatter is

pgFormatter is a free formatter for PostgreSQL SQL queries and PL/pgSQL code, with support for several SQL standards and PostgreSQL-specific keywords. The project says it also works with other databases. Formatting controls cover keyword, function, identifier, and type case, along with indentation, query wrapping, and comma placement. The command-line `--anonymize` option obscures query literals before formatting. It can run as a console program or as a CGI application that produces text or HTML; a CGI request with an `Accept: application/json` header can return JSON, although the API can be disabled in configuration. The online demo limits SQL queries to ten thousand characters. Installation instructions cover a GitHub source tarball, and the project also documents Docker use, Vim and (Neo)Vim, links to Atom and Visual Studio Code integrations, and a pre-commit hook for SQL files. For other databases, custom lists can cover functions and keywords it cannot detect automatically. pgFormatter is free software distributed under the PostgreSQL Licence.

Who it suits

pgFormatter suits developers who want to format PostgreSQL queries or PL/pgSQL code from a console, CGI setup, editor, or pre-commit workflow. It can also be configured for other databases using custom lists.

What it does well

  • Free software under the PostgreSQL Licence.
  • Offers case, indentation, wrapping, and comma controls.
  • Can obscure query literals before formatting.
  • Supports console, CGI, and JSON responses.
  • Documents editor and pre-commit integrations.

What to know first

  • Online demo limits queries to ten thousand characters.
  • Other-database functions and keywords need custom lists.

Limits

The online demo accepts SQL queries up to ten thousand characters. For other databases, pgFormatter cannot automatically detect user-defined functions or keywords, though custom lists are supported.

Plans

PlanBilled and limitsPrice
pgFormatterFree software distributed under the PostgreSQL LicenceFree

As github.com lists them, read 30 Sept 2026. The maker's own page has the final word.

Getting started

  1. Visit the pgFormatter GitHub project.
  2. Install from a GitHub source tarball using Perl Makefile.PL, make, and make install.
  3. Alternatively, build the documented Docker image and pipe SQL input to the container.
  4. Use the console program or configure it as a CGI application.
  5. Connect a documented Vim or (Neo)Vim workflow, or configure the pre-commit hook for SQL files.

Verdict

pgFormatter offers configurable SQL formatting through console and CGI use, with editor and pre-commit options. The online demo has a query-length limit, and other databases may require custom function or keyword lists.

Questions

Is pgFormatter free?

Yes. Its listed plan is free, and the project distributes it under the PostgreSQL Licence.

Which SQL dialects does pgFormatter support?

It supports SQL-92, SQL-99, SQL-2003, SQL-2008, SQL-2011, and PostgreSQL. The project also says it works with other databases.

How can I run pgFormatter?

It can run as a console program or a CGI application. The project also documents building and running a Docker image.

Does pgFormatter have editor integrations?

The README describes use with Vim and (Neo)Vim and links to Atom and Visual Studio Code integrations.

Can pgFormatter anonymize queries?

Yes. Its --anonymize command line option obscures query literals before formatting.

Who created pgFormatter?

The project credits Gilles Darold as its original author.

Facts from pgFormatter's own pages

Anonymization
The command line option --anonymize obscures query literals before formatting. · github.com, 30 Sept 2026
Docker
The project documents building a Docker image and piping SQL input to a container running pgFormatter. · github.com, 30 Sept 2026
Editor integrations
The README describes use with Vim and (Neo)Vim and links to Atom and Visual Studio Code integrations. · github.com, 30 Sept 2026
Formatting options
Options include changing keyword, function, identifier, and type case; adjusting indentation; wrapping queries; and choosing comma placement. · github.com, 30 Sept 2026
Installation
The README documents installation from a GitHub source tarball using Perl Makefile.PL, make, and make install. · github.com, 30 Sept 2026
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. · github.com, 30 Sept 2026
Maker and license
The README credits Gilles Darold as the original author and says pgFormatter is free software distributed under the PostgreSQL Licence. · github.com, 30 Sept 2026
Online demo limit
The README describes an online demo that limits SQL queries to ten thousand characters. · github.com, 30 Sept 2026
Other databases
The project says pgFormatter also works with other databases. · github.com, 30 Sept 2026
Pre-commit integration
The README documents configuring pgFormatter as a pre-commit hook for SQL files. · github.com, 30 Sept 2026
Purpose
pgFormatter beautifies PostgreSQL SQL queries and PL/pgSQL code, and supports keywords from several SQL standards as well as PostgreSQL-specific keywords. · github.com, 30 Sept 2026
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. · github.com, 30 Sept 2026
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. · github.com, 30 Sept 2026
Ways to run
It can run as a console program or a CGI application, producing text or HTML based on its environment. · github.com, 30 Sept 2026

Where pgFormatter stands on Freedom251

Look at these too