An opinionated Prettier plugin for formatting package.json files. Version 0.6.0 (stable) requires Prettier ^2.0.0 and Node >=10.13.0. Sorts package.json keys in a conventional order (inspired by @sindresorhus) and alphabetically orders keys in engines, files, and scripts sections. Unlike alternatives like prettier-plugin-package, it enforces a specific top-level key ordering and handles unknown keys by appending alphabetically. Released under MPL-2.0.
npm install prettier-plugin-package2No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Install the plugin as a dev dependency with Prettier, then format package.json using Prettier's CLI.
Ensure Prettier version is >=2.0.0 and <3.0.0 (if not tested).
Disable plugin if you need a different order, or use another plugin like prettier-plugin-package (which sorts alphabetically).
If you have custom keys that should appear in a specific position, consider using a pre-commit hook or manual ordering.
Install as dev dependency: npm install --save-dev prettier-plugin-package2
Upgrade Prettier: npm update prettier or npm install prettier@^2.0.0
Install Prettier: npm install --save-dev prettier