{"_id":"json-beautify","_rev":"19-cdfec2093cbda9f13b9d140fd540e34b","name":"json-beautify","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"json-beautify","version":"1.0.0","keywords":["json","stringify","pretty","prettify","prettifier","beautify","beautifier"],"author":{"name":"Gaëtan Renaudeau"},"license":"ISC","_id":"json-beautify@1.0.0","maintainers":[{"name":"gre","email":"renaudeau.gaetan@gmail.com"}],"homepage":"https://github.com/gre/json-beautify","bugs":{"url":"https://github.com/gre/json-beautify/issues"},"dist":{"shasum":"48ab8c12400c798899785d2e5571207acf83ff39","tarball":"https://registry.npmjs.org/json-beautify/-/json-beautify-1.0.0.tgz","integrity":"sha512-9we8tewRzxTO7Nr9ZSnvn09tj2BV97HoLcgBM9+Iwh7wcnKy4UYsoS+o5j0MZVLvUZY10NhzmP/5TKse51j4uA==","signatures":[{"sig":"MEQCIFFg98i6c7zzaSG58GgCs6XgDP3vkvLuLhF+gRvZiYzwAiA72SSY1s9mphCW6IKBTZ7y/MLyBR4gjAG2yQWNa1P5YQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"48ab8c12400c798899785d2e5571207acf83ff39","gitHead":"c783de5d7d0c4c2e25f5fcfa857d99922b0c2a94","scripts":{"test":"npm test"},"_npmUser":{"name":"gre","email":"renaudeau.gaetan@gmail.com"},"repository":{"url":"https://github.com/gre/json-beautify","type":"git"},"_npmVersion":"2.7.5","description":"JSON.stringify with fixed maximum character width.","directories":{},"_nodeVersion":"1.6.4"},"1.0.1":{"name":"json-beautify","version":"1.0.1","keywords":["json","stringify","pretty","prettify","prettifier","beautify","beautifier"],"author":{"name":"Gaëtan Renaudeau"},"license":"ISC","_id":"json-beautify@1.0.1","maintainers":[{"name":"gre","email":"renaudeau.gaetan@gmail.com"}],"homepage":"https://github.com/gre/json-beautify","bugs":{"url":"https://github.com/gre/json-beautify/issues"},"dist":{"shasum":"598b50d4c8ea9b8fca5abbb40b7e2cbd3ad4c2fc","tarball":"https://registry.npmjs.org/json-beautify/-/json-beautify-1.0.1.tgz","integrity":"sha512-OG5AeFC++jGofp+s+BjZGtC1D1+6ZZsP83pZegu/CeDRNd5KNu5wmsdEoLu2zn4KJNamJYTrWxYcezv2GwPHBA==","signatures":[{"sig":"MEYCIQDXBhu/wb8qkWaK6z5q2FD2Koy27VCDTemSLwAZn8nU+QIhANgcfNFqMTTP+cbhyPTaJIAPJPz8LCbV6jWreL1wspoV","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"598b50d4c8ea9b8fca5abbb40b7e2cbd3ad4c2fc","gitHead":"52ed474bba2ed158118996c0e58c920c2cc0e750","scripts":{"test":"npm test"},"_npmUser":{"name":"gre","email":"renaudeau.gaetan@gmail.com"},"repository":{"url":"https://github.com/gre/json-beautify","type":"git"},"_npmVersion":"2.7.5","description":"JSON.stringify with fixed maximum character width.","directories":{},"_nodeVersion":"1.6.4"},"1.1.0":{"name":"json-beautify","version":"1.1.0","keywords":["json","stringify","pretty","prettify","prettifier","beautify","beautifier"],"author":{"name":"Gaëtan Renaudeau"},"license":"ISC","_id":"json-beautify@1.1.0","maintainers":[{"name":"gre","email":"renaudeau.gaetan@gmail.com"}],"homepage":"https://github.com/gre/json-beautify","bugs":{"url":"https://github.com/gre/json-beautify/issues"},"bin":{"json-beautify":"./bin/json-beautify"},"dist":{"shasum":"5da1a4cccd0cd680d12bc6e2ff475d73ddef00c4","tarball":"https://registry.npmjs.org/json-beautify/-/json-beautify-1.1.0.tgz","fileCount":8,"integrity":"sha512-Y8lEcqhyJKRq2IhYBGtRIQO7EgOlyeSCYXnQCzAnGO5DhCBzMBEZ90PTw620NwpfQccJ/sj4+bU+r4GBI0b2Lw==","signatures":[{"sig":"MEYCIQCwFND4RqcZD1u1fahdsxcE66LOTMkcm683erFlLcXRvQIhAJbabT25kGMxZvrgdYjTaOko5qv+tzhHdh396XFOLAAI","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10051,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcp5HdCRA9TVsSAnZWagAAkbAP/iT4PePkhL9DvYh5RVM0\nXwAD+KJFL1zs3QEnQZbHENl4Noc2L/DzjMxh1imx697W0axJZpwsTOrLKy6a\nojBoRLd6SdTvTNcivEM+o+W38yNr8gFaVVNFIISE+7LAr0gzEWS5FdTnN+BC\nUj0crzD7Y6gQMq0K0OetsdRffoauZmp8fF2tfrzf2oVTXRSHEg65DkWnzKfn\nVliO575T3SNtgn7J6TArvINsvUkQsGAQWVrK226CcY2GGJdiIV86B5ugL5Xl\nLvz66ST9QOPzO1MY96wVZBiXn9WKImIfn86gANp9LiTufvmIWKVArSNaEWln\nf2jxC0k0EfdNJrvg0V6XbN1mCLUZBAn0oZa3st9xUDvJ+u0cGxaZ3MOJTNWd\n+t7PTZLKfctEP28l0fFgVDvIUfJOrksQux8CeF5GRWle8o8ozl5P1+gtfdJu\nWRQjCw+tAG8OR6pYyt6W7wWvobFXC1OzUxq3oGG8PMdIttNYCPTDxTqTeP8e\nX0thI0BPovy0SkNHx400zfysApEM89pXl7HiUuqsfhIC3boX4nZTcVQlzFUD\nLc6ydXZPDR5+u8YyPafbX8yogxTXXRxLe7nTOK7XFv2GGEStd4NDUuMh0icy\nAL3PeKwPXn7caYd1g32IadF//KPU2ww1fEyAU7/VK/5n8xDkThnZeO0RJZ0K\nYygK\r\n=nr/f\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","scripts":{"test":"npm test"},"_npmUser":{"name":"gre","email":"renaudeau.gaetan@gmail.com"},"repository":{"url":"https://github.com/gre/json-beautify","type":"git"},"description":"JSON.stringify with fixed maximum character width.","directories":{},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/json-beautify_1.1.0_1554485725096_0.8784894891225699","host":"s3://npm-registry-packages"}},"1.1.1":{"name":"json-beautify","version":"1.1.1","keywords":["json","stringify","pretty","prettify","prettifier","beautify","beautifier"],"author":{"name":"Gaëtan Renaudeau"},"license":"ISC","_id":"json-beautify@1.1.1","maintainers":[{"name":"gre","email":"renaudeau.gaetan@gmail.com"}],"homepage":"https://github.com/gre/json-beautify","bugs":{"url":"https://github.com/gre/json-beautify/issues"},"bin":{"json-beautify":"./bin/json-beautify"},"dist":{"shasum":"8a1ed511ad5d52ca63ed29f7c61896c6a6ebbb9f","tarball":"https://registry.npmjs.org/json-beautify/-/json-beautify-1.1.1.tgz","fileCount":9,"integrity":"sha512-17j+Hk2lado0xqKtUcyAjK0AtoHnPSIgktWRsEXgdFQFG9UnaGw6CHa0J7xsvulxRpFl6CrkDFHght1p5ZJc4A==","signatures":[{"sig":"MEUCIHrNV+PhJL3ONjSBbFtxgD2IffqHywr8ONE/8LxpgaEzAiEA0NTWCFek039VhfGukHhP5lis4lhuT7OqaSirftU+3I0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10313,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdf8MkCRA9TVsSAnZWagAAL6gP+QE3E/0xjl+QoM02kdGr\nuhIvJnro+lg8zvTAqSmiVH25fZ5WJhEp9UYwtIsmDNJQ2mIsMnDp5BHJkQKV\nGsskPJyNC1odefyvtWMHfaJmObmJMQXoI09+S5RUM1GzpS8QrXHaAFnQRlJZ\nIAnwcH466bV5q09eC9XBOrY0gSi+dLHMXT+KOL/+22gsYKNeXu/Y485Xl240\nNfMlxsf4Ytyxm7lujGxOETFnhoZtgCd8OSr1n7wx9eWuIaZwaQYstdpIjNdM\ngO6NLQnQi3XmG5kLXIAIf/z+cFV6u2ZL7G62KwCVKGLOdwpbFEBAppxUiBrS\nqER2h6/E3beKXVLmtm7d01PKtQioWhEYGelW75wAwl0l8/OEX96JEVkC5Wo5\nbWPRdPSl8d24RrPfG3cUsXwBe14dYBrAHGyGwniNPml7i7oCthGwnM1MnC8A\nanefw/jABPC37JJoEUL7DB/7EBEGQZD6sQYmXvJ4odJm0es/1g2+by3kGxQq\nlZ4RI4fn9skETzr7EpE41IuS83EgFRkhNHCilNILR2SZJiPkWkW2VKLuA/qq\nG97vSmiU3rSTJMOKAYEXtcb8oLiaNzM0cQR7KA29HATpyEiIS/DotR8hYMy2\nhMwETlXM/Vu+N3Y6WOIMDEw1Wfse8VTXmawmyeQ8slIptIBWKDM1QGd3Zlqg\nD705\r\n=w7vg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","scripts":{"test":"npm test"},"_npmUser":{"name":"gre","email":"renaudeau.gaetan@gmail.com"},"repository":{"url":"https://github.com/gre/json-beautify","type":"git"},"description":"JSON.stringify with fixed maximum character width.","directories":{},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/json-beautify_1.1.1_1568654115531_0.5609877972472981","host":"s3://npm-registry-packages"}},"2.0.0":{"name":"json-beautify","version":"2.0.0","description":"JSON.stringify for humans","keywords":["beautifier","beautify","json","prettifier","prettify","pretty","stringify"],"homepage":"https://github.com/gre/json-beautify","bugs":{"url":"https://github.com/gre/json-beautify/issues"},"license":"ISC","author":{"name":"Gaëtan Renaudeau"},"repository":{"type":"git","url":"git+https://github.com/gre/json-beautify.git"},"bin":{"json-beautify":"dist/bin.js"},"type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"build":"rm -rf dist && tsc -p tsconfig.build.json","pretest":"rm -rf dist && tsc -p tsconfig.json","test":"node --test dist/*.test.js","typecheck":"tsc -p tsconfig.json --noEmit","lint":"oxlint .","fmt":"oxfmt .","fmt:check":"oxfmt --check .","prepublishOnly":"npm run build"},"devDependencies":{"@types/node":"^26.1.2","oxfmt":"^0.61.0","oxlint":"^1.76.0","typescript":"^7.0.2"},"engines":{"node":">=18"},"gitHead":"a35ca506d61d7ff22ff1ed910e352efb8fa5e9bc","_id":"json-beautify@2.0.0","_nodeVersion":"25.8.2","_npmVersion":"11.11.1","dist":{"integrity":"sha512-coSzGe7M3IS+dSTbP2Ty13Bb/zMgohHr2CDVtTudob5H9KEBpJ4MzLDkyAXhU+v/1c1lxoBN1jYmly/janzniw==","shasum":"879707caa0eab3a733cbafa717b59e64de6cf9bf","tarball":"https://registry.npmjs.org/json-beautify/-/json-beautify-2.0.0.tgz","fileCount":9,"unpackedSize":39330,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD1gL41WB5bQiVqqHQOtkCk1CNH/pFkDXG17VxT4N6gDwIhALM23w8gSz2a5tDbZjYOTI0ldCF09S4dLFwSWt2oN1Ct"}]},"_npmUser":{"name":"gre","email":"renaudeau.gaetan@gmail.com"},"directories":{},"maintainers":[{"name":"gre","email":"renaudeau.gaetan@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/json-beautify_2.0.0_1785668847051_0.2059544772627424"},"_hasShrinkwrap":false}},"time":{"created":"2015-05-14T15:39:36.131Z","modified":"2026-08-02T11:07:27.325Z","1.0.0":"2015-05-14T15:39:36.131Z","1.0.1":"2015-05-14T15:47:40.771Z","1.1.0":"2019-04-05T17:35:25.207Z","1.1.1":"2019-09-16T17:15:15.661Z","2.0.0":"2026-08-02T11:07:27.201Z"},"bugs":{"url":"https://github.com/gre/json-beautify/issues"},"author":{"name":"Gaëtan Renaudeau"},"license":"ISC","homepage":"https://github.com/gre/json-beautify","keywords":["beautifier","beautify","json","prettifier","prettify","pretty","stringify"],"repository":{"type":"git","url":"git+https://github.com/gre/json-beautify.git"},"description":"JSON.stringify for humans","maintainers":[{"name":"gre","email":"renaudeau.gaetan@gmail.com"}],"readme":"json-beautify: JSON.stringify for humans\n========================================\n\n**json-beautify** is a TypeScript implementation of [ECMA-262 §25.5.4](https://tc39.es/ecma262/#sec-json.stringify), the specification of `JSON.stringify`, with one addition: objects and arrays stay on a single line for as long as they fit within a width you choose, and only break when they have to.\n\nFor every value, replacer and space it accepts, the positional form produces character-identical output to `JSON.stringify` — boxed primitives, `toJSON`, replacer arrays, `space` clamping, lone-surrogate escaping, `TypeError` on BigInt and on circular structures, and [`JSON.rawJSON`](https://github.com/tc39/proposal-json-parse-with-source) (Node 22+) all behave as the spec requires.\n\n## Install\n\n```sh\nnpm install json-beautify\n```\n\n## Usage\n\n```js\nimport beautify from \"json-beautify\";\n\nconst obj = {\n  str: \"Hello World\",\n  num: 42,\n  smallarray: [1, 2, 3, \"foo\", {}],\n  smallobject: { foo: \"bar\", bar: 42 },\n  bigarray: [1, 2, 3, \"foo\", { foo: \"bar\", bar: 42, arr: [1, 2, 3, \"foo\", {}] }],\n  bigobject: { foo: [1, 2, 3, \"foo\", {}], bar: 42, a: { b: { c: 42 } }, foobar: \"FooBar\" },\n};\n\nconsole.log(beautify(obj, {}));\n```\n\n```json\n{\n  \"str\": \"Hello World\",\n  \"num\": 42,\n  \"smallarray\": [ 1, 2, 3, \"foo\", {} ],\n  \"smallobject\": { \"foo\": \"bar\", \"bar\": 42 },\n  \"bigarray\": [\n    1,\n    2,\n    3,\n    \"foo\",\n    { \"foo\": \"bar\", \"bar\": 42, \"arr\": [ 1, 2, 3, \"foo\", {} ] }\n  ],\n  \"bigobject\": {\n    \"foo\": [ 1, 2, 3, \"foo\", {} ],\n    \"bar\": 42,\n    \"a\": { \"b\": { \"c\": 42 } },\n    \"foobar\": \"FooBar\"\n  }\n}\n```\n\nWiden it and more stays inline:\n\n```js\nconsole.log(beautify(obj, { maxWidth: 100 }));\n```\n\n```json\n{\n  \"str\": \"Hello World\",\n  \"num\": 42,\n  \"smallarray\": [ 1, 2, 3, \"foo\", {} ],\n  \"smallobject\": { \"foo\": \"bar\", \"bar\": 42 },\n  \"bigarray\": [ 1, 2, 3, \"foo\", { \"foo\": \"bar\", \"bar\": 42, \"arr\": [ 1, 2, 3, \"foo\", {} ] } ],\n  \"bigobject\": {\n    \"foo\": [ 1, 2, 3, \"foo\", {} ],\n    \"bar\": 42,\n    \"a\": { \"b\": { \"c\": 42 } },\n    \"foobar\": \"FooBar\"\n  }\n}\n```\n\n## Options\n\n| Option | Type | Default | |\n| --- | --- | --- | --- |\n| `replacer` | function \\| array \\| null | `null` | §25.5.4 `replacer`: a filter function, or an array of keys to keep. |\n| `space` | number \\| string | `2` | §25.5.4 `space`: indent width, or the literal indent string. |\n| `maxWidth` | number | `80` | Maximum line width. `0` always breaks, `Infinity` never does. |\n| `sortKeys` | boolean \\| comparator | `false` | Sort object keys instead of using their natural order. |\n| `arrayPadding` | string | `\" \"` | Padding inside a single-line array. `\"\"` gives `[1, 2]`. |\n| `objectPadding` | string | `\" \"` | Padding inside a single-line object. `\"\"` gives `{\"a\": 1}`. |\n\nAn unknown option name throws, so a typo like `maxwidth` is caught rather than silently ignored.\n\n### `sortKeys`\n\n```js\nconsole.log(beautify({ z: 1, a: { d: 1, b: 2 } }, { sortKeys: true }));\n// { \"a\": { \"b\": 2, \"d\": 1 }, \"z\": 1 }\n```\n\nPass a comparator for a custom order:\n\n```js\nbeautify(value, { sortKeys: (a, b) => a.length - b.length });\n```\n\nA `replacer` array is itself an explicit ordering, so `sortKeys` leaves it alone.\n\n### Padding\n\n```js\nbeautify({ a: [1, 2] }, {});                                  // { \"a\": [ 1, 2 ] }\nbeautify({ a: [1, 2] }, { arrayPadding: \"\" });                 // { \"a\": [1, 2] }\nbeautify({ a: [1, 2] }, { arrayPadding: \"\", objectPadding: \"\" }); // {\"a\": [1, 2]}\n```\n\n### `maxWidth` is a bound, not an estimate\n\nThe width accounts for the indent, the `\"key\": ` prefix the value sits behind, and the comma that follows it. No line exceeds `maxWidth` unless it holds a single value too long to break — a long string, or a key wider than the budget.\n\n## `JSON.stringify` compatibility\n\nThe positional signature is still supported, and is a drop-in replacement:\n\n```js\nbeautify(value, replacer, space, maxWidth);\n```\n\nCalled this way, `space` and `maxWidth` default to off rather than to `2` and `80`, so `beautify(value, replacer, space)` is exactly `JSON.stringify(value, replacer, space)`. The options form is the front door and defaults to readable output; the positional form is the compatibility path.\n\nIt is stricter than `JSON.stringify` about arguments: a malformed replacer, width or option name throws instead of being silently ignored. This affects argument validation only, never how an accepted value is serialized.\n\n## CLI\n\n```sh\nnpx json-beautify [options] <file...>\n```\n\nRewrites each file in place.\n\n```\n-w, --width <n>       maximum line width (default 80)\n-i, --indent <n|str>  indent width, or the literal indent string (default 2)\n-s, --sort-keys       sort object keys\n-c, --compact         no padding inside single-line arrays and objects\n-h, --help            show this message\n```\n\n## Development\n\n```sh\nnpm install\nnpm run build      # compile TypeScript to dist/\nnpm test           # compile + run the test suite (node:test)\nnpm run typecheck  # type-check only, no emit\nnpm run lint       # oxlint\nnpm run fmt        # oxfmt (use fmt:check in CI)\n```\n","readmeFilename":"README.md","users":{"usex":true,"laomu":true,"strobus":true,"bplok20010":true,"ruilan.yjj":true,"anlijudavid":true,"flumpus-dev":true,"willwolffmyren":true}}