{"library":"prettier-package-json","title":"Prettier Package JSON","description":"Prettier-package-json is a focused tool for formatting package.json files with consistent key ordering, script sorting, and author/contributor normalization. Version 2.8.0 is the current stable release, with active maintenance and monthly releases. It differs from generic JSON formatters by applying npm-specific rules: opinionated key order, smart script sorting (keeping pre/post scripts adjacent), filtering automatically included files from the `files` array, and expanding/contracting user objects. It provides both a CLI and programmatic API, supports pre-commit hooks via lint-staged, and is configurable via options like --expand-users. Designed for Node.js environments, it outputs valid JSON with deterministic formatting.","language":"javascript","status":"active","last_verified":"Sat Apr 25","install":{"commands":["npm install prettier-package-json"],"cli":{"name":"prettier-package-json","version":null}},"imports":["import { format } from 'prettier-package-json'","import { check } from 'prettier-package-json'","import { defaultOptions } from 'prettier-package-json'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const { format, check } = require('prettier-package-json');\nconst fs = require('fs');\n\nconst pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));\nconst formatted = format(pkg, {\n  indent: '  ',\n  expandUsers: false,\n  useTabs: false\n});\nfs.writeFileSync('./package.json', JSON.stringify(formatted, null, 2) + '\\n');\nconsole.log('Formatted package.json');\n\n// Check if already formatted\nconst isFormatted = check(pkg, { expandUsers: true });\nconsole.log('Is formatted:', isFormatted);","lang":"javascript","description":"Reads package.json, formats with indent and expandUsers options, writes back, and demonstrates the check function.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}