{"id":20380,"library":"prettier-plugin-json-sort","title":"prettier-plugin-json-sort","description":"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.","status":"active","version":"0.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/soybeanjs/prettier-plugin-json-sort","tags":["javascript","typescript"],"install":[{"cmd":"npm install prettier-plugin-json-sort","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-plugin-json-sort","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-plugin-json-sort","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency – the plugin runs as a Prettier plugin and requires Prettier >= 2.0.0","package":"prettier","optional":false}],"imports":[{"note":"The plugin is ESM-first. Use import for compatibility with Prettier's plugin resolution. CommonJS require may not work in all environments.","wrong":"const prettierPluginJsonSort = require('prettier-plugin-json-sort')","symbol":"default","correct":"import prettierPluginJsonSort from 'prettier-plugin-json-sort'"},{"note":"TypeScript types are exported. Use type import for Options if you need to specify sort behavior.","symbol":"options","correct":"import type { Options } from 'prettier-plugin-json-sort'"},{"note":"The Plugin type can be used for custom Prettier configurations.","symbol":"Plugin","correct":"import type { Plugin } from 'prettier-plugin-json-sort'"}],"quickstart":{"code":"// prettier.config.mjs\nexport default {\n  plugins: ['prettier-plugin-json-sort'],\n  // The plugin sorts package.json and tsconfig.json by default.\n  // There are no additional options yet.\n};\n\n// In your terminal:\n// npx prettier --write package.json tsconfig.json","lang":"typescript","description":"Configures Prettier to use the plugin; then runs Prettier on package.json and tsconfig.json to sort keys."},"warnings":[{"fix":"Review the sorted output and ensure compatibility with your toolchain. Consider using a more conservative sort or a selective configuration.","message":"The plugin may sort JSON keys in ways that break tools expecting a specific order (e.g., some parsers).","severity":"breaking","affected_versions":">=0.0.1"},{"fix":"If you need nested key sorting, you must manually sort or use another plugin.","message":"Only top-level keys are sorted – nested keys are not affected.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"If you want to sort other JSON files, consider using a more general JSON sorting plugin or a custom Prettier parser.","message":"The plugin only sorts package.json and tsconfig.json by default – other JSON files are ignored.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Pin the exact version in your package.json if stability is critical. Watch the repository for updates.","message":"Version 0.0.2 is very early; future versions may change sorting behavior or introduce breaking changes without major version bump.","severity":"deprecated","affected_versions":"0.0.1-0.0.2"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install prettier-plugin-json-sort --save-dev","cause":"The plugin is not installed or not in node_modules.","error":"Cannot find module 'prettier-plugin-json-sort'"},{"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.","cause":"Prettier cannot locate the plugin module, possibly due to a misconfiguration in prettier.config.js or run from a different directory.","error":"Error: Cannot find plugin 'prettier-plugin-json-sort' in plugins list"},{"fix":"Only run prettier --write on package.json or tsconfig.json, or configure the plugin to target those files specifically via file matching.","cause":"Prettier tries to process a file that is not package.json or tsconfig.json with this plugin, which only supports those two types.","error":"Error: Unsupported file type"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}