Prettier plugin that automatically sorts the keys in package.json files. Current stable version is 1.1.0, released in April 2025. This plugin is a zero-dependency, opinionated tool that works out of the box with no configuration. It supports all keys defined in the npm v11 package.json documentation and also provides a custom parser for sorting package.json-like files. Unlike alternatives (e.g., sort-package-json standalone CLI), it integrates directly into Prettier's workflow, enabling auto-formatting on save and consistent sorting across teams without extra scripts.
npm install prettier-plugin-sort-package-jsonVerified import paths — ran on the pinned version, not inferred.
Installs the plugin, adds it to Prettier config, and formats package.json with automatic sorting.
No action needed — order is now consistent with npm docs. Run Prettier to update files.
Upgrade to latest: npm install -D prettier-plugin-sort-package-json@latest
Add overrides to .prettierrc: { "files": ["pkg.json"], "options": { "parser": "sort-package-json" } }Ensure Prettier version is ^3.0.0: npm install -D prettier@3
Use --plugin=prettier-plugin-sort-package-json or just add to config.
npm install -D prettier-plugin-sort-package-json
Add "plugins": ["prettier-plugin-sort-package-json"] to Prettier config
Update Prettier to v3 or higher: npm install -D prettier@latest