A Prettier plugin that sorts JSON files alphanumerically by key. Version 4.2.0, actively maintained with regular releases. It supports custom sort orders, case-insensitive sorting, numeric sorting, and category-based sorting. Differentiators include deterministic key order for case-insensitive sorts, support for Prettier v3 (ESM), and TypeScript types. Requires Node.js >=18 and Prettier ^3.0.0.
npm install prettier-plugin-sort-jsonVerified import paths — ran on the pinned version, not inferred.
Shows how to configure Prettier with the plugin and a custom sort order, sorting 'name' and 'version' keys alphabetically and leaving others unsorted.
Upgrade to Node.js >=18.0.0
Review JSON files that relied on original order for case-insensitive sorts; keys with same case may now be sorted differently
Explicitly add plugin to prettier configuration (e.g., `plugins: ['prettier-plugin-sort-json']`)
Update configuration to use JSON string instead of path (e.g., {"name": "alphabetical"})Downgrade to prettier-plugin-sort-json@2 for Prettier v2, or upgrade to Prettier v3
Set jsonSortOrder in prettier config or upgrade to v4.1.1+
Add `plugins: ['prettier-plugin-sort-json']` to your Prettier config (e.g., .prettierrc.js)
Replace the file path with a JSON string like `{"name": "alphabetical"}`Ensure jsonSortOrder is valid JSON and uses allowed sort options: alphabetically, natural, caseInsensitive, caseSensitive, none
Use `import` or in CJS: `const plugin = require('prettier-plugin-sort-json').default`