Registry / serialization / prettier-plugin-expand-json

prettier-plugin-expand-json

JSON →
library1.0.4jsnpmunverified

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).

npm install prettier-plugin-expand-json
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-EX
P
prettier-plugin-expand-json
serializationjavascriptv1.0.4
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
in .prettierrc: { "plugins": ["prettier-plugin-expand-json"] }
const plugin = require('prettier-plugin-expand-json')
Plugin is consumed via Prettier configuration, not imported directly in code.

Install plugin, configure Prettier, and format a JSON file to always expand arrays/objects to multi-line.

npm install --save-dev prettier prettier-plugin-expand-json echo '{"plugins":["prettier-plugin-expand-json"]}' > .prettierrc echo '{"a":1,"b":[2,3]}' > test.json npx prettier --write test.json cat test.json # Output: # { # "a": 1, # "b": [ # 2, # 3 # ] # }
Debug
Known issues
gotchaPlugin 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.
fix
Ensure 'prettier-plugin-expand-json' is the last element in the 'plugins' array in your Prettier config.
affects: >=1.0.0
breakingMinimum Node engine is >=20. Using older Node versions will cause errors.
fix
Upgrade to Node 20 or later.
affects: >=1.0.0
gotchaPlugin does not provide any options; it forces expansion of all arrays and objects. If you need selective expansion, consider other tools.
fix
No workaround; designed to always expand.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'prettier-plugin-expand-json'
Plugin not installed or not in node_modules, or Prettier cannot locate it.
fix
Run `npm install --save-dev prettier-plugin-expand-json` and ensure your working directory contains node_modules.
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/prettier-plugin-expand-json/index.js from /path/to/prettier/index.js not supported.
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).
fix
Upgrade Prettier to version 3 or later: `npm install --save-dev prettier@3`.
[error] prettier-plugin-expand-json: No parser found for file extension: .json
Prettier is not configured to use JSON parser for .json files, or another plugin overrides the parser.
fix
Ensure Prettier config includes `"plugins": ["prettier-plugin-expand-json"]` and that the plugin is listed last if multiple plugins are used.
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies
prettierrequiredpeer dependency, required to run as a plugin
Agent activity
6 hits · last 30 days
node
6
Resources
prettier-plugin-expand-json — npm install prettier-plugin-expand-json · libregistry