Skip to content package
pg-formatter v2.1.0 PostgreSQL SQL syntax beautifier.
node >=16 3 deps cjs types open source
overview readme
license BSD-3-Clause
deps 3
unpacked 6.4 MB
files 598
node >=16 $ npm install pg-formatter@2.1.0n npmREADME GitHub-flavored package documentation.
downloads Across all versions.
Download trend unavailable.
compatibility Runtime metadata.
keywords Tagged topics.
beautifier formatter postgres sql
versions Latest published Oct 23, 2026
maintainers Registry package owners.
contents
A PostgreSQL SQL syntax beautifier.
Note:
This project is a thin wrapper of https://github.com/darold/pgFormatter .
Execution of the module relies on Perl being available on the host system.
Usage
import {
format
} from 'pg-formatter' ;
format ( `SELECT foo FROM bar` );
copy
Configuration
Configuration Format Default Description pgFormatter equivalentanonymizeboolean falseObscure all literals in queries, useful to hide confidential data before formatting. anonymizecommaBreakboolean falseAdd a newline after each comma in an insert statement. comma-breakfunctionCasestring ("unchanged", "lowercase", "uppercase", "capitalize") unchangedChange the case of the function names. function-casekeywordCasestring ("unchanged", "lowercase", "uppercase", "capitalize")
CLI Usage
$ npm install pg-formatter -g
$ pg-formatter --help
Formats SQL files
Options:
--version Show version number [boolean]
--anonymize Obscure all literals in queries, useful to hide
confidential data before formatting.
[boolean] [default: false]
--comma-break Add a newline after each comma in an insert statement.
[boolean] [default: false]
--function-case Change the case of the function names.
install size Estimated unpacked size across 26 packages.
11.7 MB
Includes dependencies.
dependencies 3 direct · 1 outdated
unchanged
Change the case of the reserved keyword.
noRcFileboolean falseDo not read ~/.pg_format automatically. no-rcfile
placeholderstring (regex) N/A Regex to find code that must not be changed. placeholder
spacesnumber 4Number of spaces to indent the code. spaces
stripCommentsboolean falseRemove any comment from SQL code. nocomment
tabsboolean falseUse tabs instead of spaces. When true, the spaces option is ignored. tabs
[string] [choices: "unchanged" , "lowercase" , "uppercase" , "capitalize" ]
[default: "unchanged" ]
-i, --inplace Override input file with formatted content.
[boolean] [default: false]
--keyword-case Change the case of the reserved keyword.
[string] [choices: "unchanged" , "lowercase" , "uppercase" , "capitalize" ]
[default: "unchanged" ]
--no-rc-file Do not read ~/.pg_format automatically.
[boolean] [default: false]
--placeholder Regex to find code that must not be changed. [string]
--spaces Number of spaces to indent the code.
[number] [default: 4]
--strip-comments Remove any comment from SQL code.
[boolean] [default: false]
--tabs Use tabs instead of spaces. When true, the spaces option
is ignored. [boolean] [default: false]
--help Show help [boolean]
copy