pkg-json-sort-cli
v1.0.0
Published
Sort package.json keys in a standard, consistent order
Downloads
142
Maintainers
Readme
pkg-json-sort-cli
Sort package.json keys in a standard, consistent order.
Install
npm install -g pkg-json-sort-cliUsage
# Show sorted output (no changes written)
pkg-json-sort-cli
# Sort and write in place
pkg-json-sort-cli --write
# Check if sorted (CI-friendly, exits 1 if unsorted)
pkg-json-sort-cli --check
# Dry run — show diff without writing
pkg-json-sort-cli --dry-run
# Custom path and indent
pkg-json-sort-cli -p ./packages/app/package.json --indent 4 --writeOptions
| Flag | Description |
|---|---|
| -p, --path <path> | Path to package.json (default: package.json) |
| --check | Check only, exit 1 if unsorted |
| --write | Write sorted file in place |
| --indent <size> | Indentation size (default: 2) |
| --dry-run | Show changes without writing |
Key Order
Keys are sorted in this standard order:
name → version → description → keywords → homepage → bugs → license → author → contributors → funding → files → main → module → types → exports → bin → scripts → dependencies → devDependencies → peerDependencies → optionalDependencies → engines → os → cpu → repository → publishConfig → workspaces → private
Any keys not in this list are appended alphabetically at the end.
Dependency objects (dependencies, devDependencies, peerDependencies, optionalDependencies) have their entries sorted alphabetically.
License
MIT
