{"id":20363,"library":"prettier-plugin-expand-json","title":"Prettier Plugin Expand JSON","description":"Prettier plugin that expands all JSON arrays and objects into multi-line format, ensuring consistent formatting for JSON and JSONC files. Current stable version 1.0.4, released with no dependencies. Engine requires Node >=20. Unlike default Prettier behavior which may collapse short objects, this plugin always forces multi-line output. Works with special files like package.json and composer.json, and can be combined with other JSON plugins (must be listed last).","status":"active","version":"1.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/porada/prettier-plugin-expand-json","tags":["javascript","formatting","json","jsonc","prettier","prettier-plugin","typescript"],"install":[{"cmd":"npm install prettier-plugin-expand-json","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-plugin-expand-json","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-plugin-expand-json","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency, required to run as a plugin","package":"prettier","optional":false}],"imports":[{"note":"Plugin is consumed via Prettier configuration, not imported directly in code.","wrong":"const plugin = require('prettier-plugin-expand-json')","symbol":"default","correct":"in .prettierrc: { \"plugins\": [\"prettier-plugin-expand-json\"] }"}],"quickstart":{"code":"npm install --save-dev prettier prettier-plugin-expand-json\necho '{\"plugins\":[\"prettier-plugin-expand-json\"]}' > .prettierrc\necho '{\"a\":1,\"b\":[2,3]}' > test.json\nnpx prettier --write test.json\ncat test.json\n# Output:\n# {\n#   \"a\": 1,\n#   \"b\": [\n#     2,\n#     3\n#   ]\n# }","lang":"javascript","description":"Install plugin, configure Prettier, and format a JSON file to always expand arrays/objects to multi-line."},"warnings":[{"fix":"Ensure 'prettier-plugin-expand-json' is the last element in the 'plugins' array in your Prettier config.","message":"Plugin must be listed last in the plugins array when combined with other JSON plugins (e.g., prettier-plugin-sort-json, prettier-plugin-pkg). If not, other plugins may override the formatting.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade to Node 20 or later.","message":"Minimum Node engine is >=20. Using older Node versions will cause errors.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"No workaround; designed to always expand.","message":"Plugin does not provide any options; it forces expansion of all arrays and objects. If you need selective expansion, consider other tools.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install --save-dev prettier-plugin-expand-json` and ensure your working directory contains node_modules.","cause":"Plugin not installed or not in node_modules, or Prettier cannot locate it.","error":"Cannot find module 'prettier-plugin-expand-json'"},{"fix":"Upgrade Prettier to version 3 or later: `npm install --save-dev prettier@3`.","cause":"Prettier is loading the plugin via require(), but the plugin is ESM-only (since v1). This happens if Prettier version is <3 (which used CJS).","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/prettier-plugin-expand-json/index.js from /path/to/prettier/index.js not supported."},{"fix":"Ensure Prettier config includes `\"plugins\": [\"prettier-plugin-expand-json\"]` and that the plugin is listed last if multiple plugins are used.","cause":"Prettier is not configured to use JSON parser for .json files, or another plugin overrides the parser.","error":"[error] prettier-plugin-expand-json: No parser found for file extension: .json"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}