A Prettier plugin that uses the official libpg_query parser to format PostgreSQL SQL. Currently in beta (v0.2.3) with support for core DML and DDL constructs including SELECT, INSERT, UPDATE, DELETE, CTEs, window functions, CREATE TABLE, ALTER TABLE, indexes, views, functions, triggers, and more. Compared to generic SQL formatters, this plugin uses PostgreSQL's own parser for accurate syntax understanding and respects optional parentheses in WHERE clauses (default: minimal). Release cadence is monthly. Node >=20 and Prettier >=3 required. Ships TypeScript types.
npm install prettier-plugin-postgresqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Install, configure, and run prettier on a SQL file to format PostgreSQL queries.
Review formatted output; file issues for unknown constructs; consider using a different formatter for unsupported SQL.
Ensure your SQL uses PostgreSQL 16 compatible syntax; upgrade plugin when libpg_query updates.
Set pgFunctionNameCase: 'uppercase' explicitly if you want uppercase function names.
Only use this plugin for PostgreSQL SQL files; use file-based parser overrides in Prettier.
Set parser: 'sql' in Prettier config, or use file extensions like .sql mapped via overrides.
Pin to exact version: "prettier-plugin-postgresql": "0.2.3" in package.json.
Add the plugin to your Prettier config: { "plugins": ["prettier-plugin-postgresql"] }Run: npm install --save-dev prettier-plugin-postgresql (ensure prettier is also installed)
Upgrade Prettier to v3: npm install --save-dev prettier@latest
Edit the output to replace the unknown placeholder with valid SQL or file an issue on GitHub.