PostgreSQL SQL syntax beautifier wrapping the Perl-based pgFormatter. v1.33.0 (released 2023-01-15) provides a CLI and JavaScript API for formatting SQL files, with options for indentation, keyword casing, comma placement, and comment removal. Key differentiators: specifically targets PostgreSQL dialect, supports extensive formatting rules (keywordCase, functionCase, typeCase), and offers both library and CLI usage. Requires Perl runtime. Actively maintained with monthly releases.
npm install psqlformatNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates formatting a SQL string with custom options (2 spaces, lowercase keywords) using the ESM module.
Install Perl via your package manager (e.g., 'sudo apt-get install perl' on Ubuntu, or 'brew install perl' on macOS).
Use dynamic import: const psqlformat = await import('psqlformat'); or import statement in an ESM context.Use '--commaEnd=false' instead.
For large files, use formatFromFile which reads the file in chunks.
Install Perl (e.g., sudo apt-get install perl) and ensure it's accessible.
Use import instead of require, or convert your project to ESM.