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.
- 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.
- 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.
- sqlfluff/sqlfluff
Formats SQL and also checks it against rules you choose, which is more useful in a team and much slower to set up.
Track this in Scout - tconbeer/sqlfmt
Formats to one fixed style with almost no settings, in the way Black formats Python, and is aimed at dbt projects.
Track this in Scout - sql-formatter-org/sql-formatter
A JavaScript formatter covering many database dialects, which suits putting a formatter inside your own web page.
Track this in Scout
# 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/
