Registry / devops / prettier-plugin-json-sort

prettier-plugin-json-sort

JSON →
library0.0.2jsnpmunverified

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-sort
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-JS
P
prettier-plugin-json-sort
devopsjavascriptv0.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import prettierPluginJsonSort from 'prettier-plugin-json-sort'
const prettierPluginJsonSort = require('prettier-plugin-json-sort')
The plugin is ESM-first. Use import for compatibility with Prettier's plugin resolution. CommonJS require may not work in all environments.
options
import type { Options } from 'prettier-plugin-json-sort'
TypeScript types are exported. Use type import for Options if you need to specify sort behavior.
Plugin
import type { Plugin } from 'prettier-plugin-json-sort'
The Plugin type can be used for custom Prettier configurations.

Configures Prettier to use the plugin; then runs Prettier on package.json and tsconfig.json to sort keys.

// prettier.config.mjs export default { plugins: ['prettier-plugin-json-sort'], // The plugin sorts package.json and tsconfig.json by default. // There are no additional options yet. }; // In your terminal: // npx prettier --write package.json tsconfig.json
prettier --version
Debug
Known issues
breakingThe plugin may sort JSON keys in ways that break tools expecting a specific order (e.g., some parsers).
fix
Review the sorted output and ensure compatibility with your toolchain. Consider using a more conservative sort or a selective configuration.
affects: >=0.0.1
gotchaOnly top-level keys are sorted – nested keys are not affected.
fix
If you need nested key sorting, you must manually sort or use another plugin.
affects: >=0.0.1
gotchaThe plugin only sorts package.json and tsconfig.json by default – other JSON files are ignored.
fix
If you want to sort other JSON files, consider using a more general JSON sorting plugin or a custom Prettier parser.
affects: >=0.0.1
deprecatedVersion 0.0.2 is very early; future versions may change sorting behavior or introduce breaking changes without major version bump.
fix
Pin the exact version in your package.json if stability is critical. Watch the repository for updates.
affects: 0.0.1-0.0.2
Errors
Common errors & fixes
Cannot find module 'prettier-plugin-json-sort'
The plugin is not installed or not in node_modules.
fix
npm install prettier-plugin-json-sort --save-dev
Error: Cannot find plugin 'prettier-plugin-json-sort' in plugins list
Prettier cannot locate the plugin module, possibly due to a misconfiguration in prettier.config.js or run from a different directory.
fix
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.
Error: Unsupported file type
Prettier tries to process a file that is not package.json or tsconfig.json with this plugin, which only supports those two types.
fix
Only run prettier --write on package.json or tsconfig.json, or configure the plugin to target those files specifically via file matching.
Upgrade
Version history
0.0.2latest on npm
Audit
Dependencies
prettierrequiredPeer dependency – the plugin runs as a Prettier plugin and requires Prettier >= 2.0.0
Agent activity
4 hits · last 30 days
node
4
Resources
prettier-plugin-json-sort — npm install prettier-plugin-json-sort · libregistry