An opinionated package.json formatter plugin for Prettier, enforcing a consistent key ordering style popularized by Sindre Sorhus. v2.0.0 requires Node >=20.19.0 and Prettier ^3.0.0. It sorts top-level keys, and alphabetizes scripts, files, and engines. Differentiates from other package.json formatters by its strict opinionated ordering and automatic key classification. Released under MPL-2.0, maintained by shellscape, with monthly releases.
npm install prettier-plugin-packageVerified import paths — ran on the pinned version, not inferred.
Demonstrates automatic sorting of keys and scripts in package.json after running Prettier with the plugin.
Upgrade Node.js to v20.19.0 or later, or use prettier-plugin-package@1.4.0 for Node 14+ and Prettier v2.
Use prettier-plugin-package@1.4.0 for Prettier v2, or @0.3.1 for Prettier v1.
Ensure you use Prettier v2+ and run via standard prettier --write. No migration steps required.
Review resulting package.json order; if custom keys appear in unexpected order, consider renaming keys to match alphabetical order or accept the opinionated sort.
Verify that your files array after formatting includes all intended entries; the plugin ensures README.md and LICENSE are last if present.
Run npm install --save-dev prettier-plugin-package. Ensure prettier is also installed.
Run Prettier explicitly on package.json: npx prettier --write package.json
Upgrade Node.js to >=20.19.0 or downgrade plugin to v1.4.0 using npm install prettier-plugin-package@1.4.0 --save-dev
Install prettier v3: npm install prettier@^3.0.0 or downgrade plugin to v1.4.0 with npm install prettier-plugin-package@1.4.0 --save-dev