A Prettier plugin that automatically sorts the keys in package.json and tsconfig.json files. At version 0.0.2, it is in early development with a single feature: sorting top-level keys in JSON configuration files. Unlike other sorting plugins (e.g., prettier-plugin-pkg), it focuses specifically on two JSON schemas. It ships TypeScript types and requires Prettier >= 2.0.0 as a peer dependency. Release cadence is irregular, and breaking changes are possible at this early stage.
npm install prettier-plugin-json-sortVerified import paths — ran on the pinned version, not inferred.
Configures Prettier to use the plugin; then runs Prettier on package.json and tsconfig.json to sort keys.
Review the sorted output and ensure compatibility with your toolchain. Consider using a more conservative sort or a selective configuration.
If you need nested key sorting, you must manually sort or use another plugin.
If you want to sort other JSON files, consider using a more general JSON sorting plugin or a custom Prettier parser.
Pin the exact version in your package.json if stability is critical. Watch the repository for updates.
npm install prettier-plugin-json-sort --save-dev
Ensure plugins array includes the package name as a string (e.g., plugins: ['prettier-plugin-json-sort']). Run prettier from the project root where the plugin is installed.
Only run prettier --write on package.json or tsconfig.json, or configure the plugin to target those files specifically via file matching.