Data and databases · Edition No. 22 · 16 Sep 2026

darold/pgFormatter

Lays out an unreadable SQL query so a person can read it, from the command line or as a web page.

← Data and databasesRead the whole edition →
07

darold/pgFormatter

💎 hidden gem

2.0k stars · PostgreSQL licence · v5.11 (2026-09-04), read from /releases/latest; the release notes state the full date, September 4 2026 · Track this in Scout

Lays out an unreadable SQL query so a person can read it, from the command line or as a web page.

Repo detailsthe review · specs · pros & cons · install

What it is

A SQL formatter written in Perl, by the author of pgBadger, which was Edition 18 #6. It understands PostgreSQL syntax properly, including the parts most formatters get wrong, and it can also colour the output as HTML for a web page. It runs as a command, as a filter in an editor, or as a small web page you host yourself.What it is good for. Anyone whose SQL is written by somebody else, and today that often means a coding assistant. The problem it removes is a review you skip because the text is unreadable. You build everything with Claude Code, so a large share of Grasppy's queries arrive fully formed, and running them through this before they are committed is the difference between reading them and trusting them. It also makes the slow queries that pgBadger (Edition 18 #6) names legible when you go to look at them.

Stars2.0k
LicencePostgreSQL licence
Latestv5.11 (2026-09-04), read from /releases/latest; the release notes state the full date, September 4 2026
Good
  • One command, instant, and it can edit the file in place so it fits into saving a file.
  • It knows PostgreSQL specifically, so it does not mangle the parts that are not standard SQL.
  • The PostgreSQL licence is as permissive as MIT, and there is a public demo page if you only need it once.
Watch for
  • It formats and nothing else. It will not tell you a query is wrong or slow.
  • It is a Perl program, which is already on most Linux servers but is one more thing on a Mac.
  • Its own defaults may not match your house style, and getting the settings right takes a few tries.
Similar repositories
Install
# Debian or Ubuntu:
sudo apt install pgformatter
# Or from source; it is a Perl program with no dependencies to speak of:
git clone https://github.com/darold/pgFormatter.git
cd pgFormatter
perl Makefile.PL
make && sudo make install
# Format a file, replacing it:
pg_format -i my_query.sql
# Or paste a query into the demo page:
#   http://sqlformat.darold.net/
Screenshots
darold/pgFormatter: GitHub preview card

Get the next edition in your inbox

A dozen repositories, opened and checked. The licence read, the last release dated, and the ones that did not make it named with the reason. It is the half most lists leave out.

No tracking pixels. One click to leave. The archive stays free either way.

We use your address to send the edition and nothing else. Confirm by email, leave in one click. How we handle it.