PgSanity
PgSanity: A focused PostgreSQL syntax checker for command-line and pre-commit workflows. Ranked #23 of 25 in SQL Linters and Formatters by our editors (6.3/10); pricing: Free plan; best for postgreSQL syntax checks in pre-commit.
At a glance
- Editor score6.3 / 10
- PricingFree plan
- Best forPostgreSQL syntax checks in pre-commit
- Free planYes
- Paid fromFree
- Supported SQL dialectsPostgreSQL
- Facts checked20 Sep 2026

Where it wins
- Uses PostgreSQL’s parser for focused syntax checks
- Accepts multiple files or SQL from standard input
- Reports error locations and works as a pre-commit hook
Where it doesn't
- Supports PostgreSQL syntax rather than multiple SQL dialects
- Requires Python and ecpg for installation and operation
- Does not provide verified formatting, autofix, editor, or CI breadth
Our verdict on PgSanity
PgSanity is an open-source command-line utility for checking PostgreSQL SQL syntax. It is aimed at developers and teams that want a focused validation step for SQL files, scripts, or pre-commit workflows. The tool uses ecpg, which relies on PostgreSQL’s parser, to identify syntax errors and report their locations and messages. It accepts one or multiple filenames, or reads SQL from standard input when no filenames are supplied. PgSanity runs on Linux and is distributed through pip or uv.
Its main strength is parser alignment: checks use PostgreSQL’s own parsing path rather than a generic SQL interpretation. That makes the tool a focused fit for PostgreSQL repositories where syntax validation matters more than a broad database-linting feature set. Exit status 0 indicates valid syntax, while status 1 indicates that errors were found, giving command-line workflows a clear result to act on. The pre-commit integration also places checks directly into a source-control workflow, while standard input support can suit pipelines and generated SQL.
Setup is oriented toward command-line environments and requires Python and ecpg, so teams should account for those dependencies when preparing development systems or automation. PgSanity stays narrow: it checks syntax but does not provide verified SQL formatting or autofix, and its published positioning does not extend to editor or broader CI capabilities. Choose it when PostgreSQL-only syntax checks, file handling, standard input, and pre-commit integration are the priority. Choose a broader SQL tool instead when formatting, automatic corrections, editor integration, or wider workflow coverage are central requirements.
Your product? Our editors can test PgSanity in depth and publish a review, labelled as paid · from $149/mo →
PgSanity pricing
PgSanity fact sheet
| Free plan | Yes |
|---|---|
| Paid from | Free |
| Supported SQL dialects | PostgreSQL |
| Automatic fixes | Not verified |
| Custom rules | Not verified |
| Editor extensions | Not verified |
| CI/CD integration | Not verified |
| Configuration file | Not verified |
| Deployment | Self-hosted |
| Platforms | Linux |
| Support | Community, Docs |
| Built for | Solo, Small business, Mid-market, Enterprise (editorial estimate) |
| Integrations | 1 integrations: pre-commit |
| Pricing | Free plan |
| Website | github.com |
| Facts checked | 20 Sep 2026 |
PgSanity integrations
PgSanity lists 1 integrations on its own site.
- pre-commit
Alternatives to PgSanity
- SQLFluffConfigurable SQL linting with autofix, templating, plugins, and CI workflows.9.4
- SqruffA focused open-source choice for dbt teams needing linting, formatting, and CI workflows.9.1
- pgFormatterA configurable, open-source formatter for PostgreSQL-focused SQL workflows.8.8
See all PgSanity alternatives →
Used PgSanity? Be the first to review it
The editor score above is our own research. What this page doesn't have yet is a reader's view — what you used PgSanity for, what worked and what didn't. No stars are seeded and no review is paid for; an editor reads every one before it appears.
Write a reviewTwo minutes · verified accounts only · read by an editor before it appears
Featured on iTechGuides
PgSanity is listed in our SQL Linters and Formatters directory. Add the badge to your site — it links back to this page.
<a href="https://www.itechguides.com/products/pgsanity/"><img src="https://www.itechguides.com/best/badge/pgsanity.svg" alt="Featured on iTechGuides" width="230" height="46"></a>
Reviewed by iTechGuides Editors · Editorial team · Updated Oct 2026
Advertiser disclosure: iTechGuides is reader-supported. Vendors can pay for top positions in our rankings and for a place on other products' pages, and we may earn a commission when you click some links. Bought places stand at the number bought; this page and our disclosure say so. Paying vendors may get a fuller, more detailed review from our editors, and that review can change their score. How we rank.
Last updated · How we research and update
