{"_id":"safe-stringify","_rev":"11-1f09ba8afc6335c17805fccd92a21e09","name":"safe-stringify","dist-tags":{"latest":"1.3.0"},"versions":{"0.0.0":{"name":"safe-stringify","version":"0.0.0","keywords":["node","json","stringify","cycle"],"author":{"name":"Ned Rockson","email":"nedrocks@gmail.com"},"license":"MIT","_id":"safe-stringify@0.0.0","maintainers":[{"name":"nedrocks","email":"ned@nedrockson.com"}],"homepage":"https://github.com/nedrocks/safe-stringify#readme","bugs":{"url":"https://github.com/nedrocks/safe-stringify/issues"},"dist":{"shasum":"802592812532138562ffed1219cc5487889ad9e5","tarball":"https://registry.npmjs.org/safe-stringify/-/safe-stringify-0.0.0.tgz","integrity":"sha512-3pVK1pYSxzF15QoXRevu3qufoM77X1gnuh18tGKEk1pFpnNWBmmJ2nAqrZgIx+vylgICpLk8pdwP03n8hRDbew==","signatures":[{"sig":"MEQCIF2lBRjD5VAVVEEMn5p3KZltm6AAf7m1IlAiXPZhNctGAiBgJ9XZs/iZh8kg+lOKoYT9GftMc/HKA4sX8vclGhP2pw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"jest":{"scriptPreprocessor":"<rootDir>/node_modules/babel-jest","testFileExtensions":["es6","js"],"moduleFileExtensions":["js","json","es6"],"unmockedModulePathPatterns":["<rootDir>/node_modules/babel-runtime"]},"main":"index.js","_from":".","_shasum":"802592812532138562ffed1219cc5487889ad9e5","gitHead":"8e9f5a3357a1b5941d5564e62e1e224da6a59d66","scripts":{"test":"jest"},"_npmUser":{"name":"nedrocks","email":"ned@nedrockson.com"},"repository":{"url":"git+https://github.com/nedrocks/safe-stringify.git","type":"git"},"_npmVersion":"3.9.5","description":"A safe substitute for JSON.stringify","directories":{},"_nodeVersion":"6.2.2","devDependencies":{"babel":"^6.5.2","jest-cli":"^13.2.3","babel-cli":"^6.10.1","babel-jest":"^13.2.2","babel-preset-es2015":"^6.9.0","babel-preset-stage-0":"^6.5.0","babel-plugin-transform-flow-strip-types":"^6.8.0"},"_npmOperationalInternal":{"tmp":"tmp/safe-stringify-0.0.0.tgz_1468454345459_0.16170724341645837","host":"packages-12-west.internal.npmjs.com"}},"0.0.1":{"name":"safe-stringify","version":"0.0.1","keywords":["node","json","stringify","cycle"],"author":{"name":"Ned Rockson","email":"nedrocks@gmail.com"},"license":"MIT","_id":"safe-stringify@0.0.1","maintainers":[{"name":"nedrocks","email":"ned@nedrockson.com"}],"homepage":"https://github.com/nedrocks/safe-stringify#readme","bugs":{"url":"https://github.com/nedrocks/safe-stringify/issues"},"dist":{"shasum":"3091f9381a886634ab461a75d31208149a45616d","tarball":"https://registry.npmjs.org/safe-stringify/-/safe-stringify-0.0.1.tgz","integrity":"sha512-HlrC4wumvhUAOln+BixHSTdKIOQTz/zBXUp6eY8r+AzGTpvT4pqrsKhj/qhMzj49pqALvCzWGL4IDUizvBWefw==","signatures":[{"sig":"MEUCIA2rUIXVICrQ+DORhiQm4DmPkoFQb7W3LBDVAXi9my2tAiEAsYwG3lptsnMubhprdszwqsVOjTljQlL8CbVKcb3dQ6k=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"jest":{"scriptPreprocessor":"<rootDir>/node_modules/babel-jest","testFileExtensions":["es6","js"],"moduleFileExtensions":["js","json","es6"],"unmockedModulePathPatterns":["<rootDir>/node_modules/babel-runtime"]},"main":"index.js","_from":".","_shasum":"3091f9381a886634ab461a75d31208149a45616d","gitHead":"f524a8ebfde8bc9b137b63b33568c097e887dc72","scripts":{"test":"jest"},"_npmUser":{"name":"nedrocks","email":"ned@nedrockson.com"},"repository":{"url":"git+https://github.com/nedrocks/safe-stringify.git","type":"git"},"_npmVersion":"3.9.5","description":"A safe substitute for JSON.stringify","directories":{},"_nodeVersion":"6.2.2","devDependencies":{"babel":"^6.5.2","jest-cli":"^13.2.3","babel-cli":"^6.10.1","babel-jest":"^13.2.2","babel-preset-es2015":"^6.9.0","babel-preset-stage-0":"^6.5.0","babel-plugin-transform-flow-strip-types":"^6.8.0"},"_npmOperationalInternal":{"tmp":"tmp/safe-stringify-0.0.1.tgz_1468454507465_0.41487714159302413","host":"packages-12-west.internal.npmjs.com"}},"1.1.0":{"name":"safe-stringify","version":"1.1.0","keywords":["json","stringify","safe","circular","destroy","serialize","encode","cyclic","object"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"safe-stringify@1.1.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/safe-stringify#readme","bugs":{"url":"https://github.com/sindresorhus/safe-stringify/issues"},"dist":{"shasum":"9fc0c792eeb4cc86da3d7df53afafab3df332550","tarball":"https://registry.npmjs.org/safe-stringify/-/safe-stringify-1.1.0.tgz","fileCount":5,"integrity":"sha512-GQtvNzmfVbumWXSGW1WAQy+KgxGChBShulCXoAKFh4GPOvQ45504EQkoC+W48Yb3f43Iozfx6F3oxykhnDMJ3w==","signatures":[{"sig":"MEUCIE7idBMm0+avOAAmPRg6sCFAM79kG1ukAs47Yx9FkEl3AiEAmznMg+N1Lb+dIEKDblxWL35jkgL+533+F4uylCeF/uc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4492},"type":"module","types":"./index.d.ts","engines":{"node":">=16"},"exports":{"types":"./index.d.ts","default":"./index.js"},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"41b382626cb8a18ffbcb79d94efc9db9e2ab643e","scripts":{"test":"xo && ava && tsd"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/safe-stringify.git","type":"git"},"_npmVersion":"9.2.0","description":"Serialize objects to JSON with handling for circular references","directories":{},"sideEffects":false,"_nodeVersion":"20.9.0","_hasShrinkwrap":false,"devDependencies":{"xo":"^0.54.2","ava":"^5.2.0","tsd":"^0.28.1"},"_npmOperationalInternal":{"tmp":"tmp/safe-stringify_1.1.0_1699294586885_0.19006250175571582","host":"s3://npm-registry-packages"}},"1.1.1":{"name":"safe-stringify","version":"1.1.1","keywords":["json","stringify","safe","circular","destroy","serialize","encode","cyclic","object"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"safe-stringify@1.1.1","homepage":"https://github.com/sindresorhus/safe-stringify#readme","bugs":{"url":"https://github.com/sindresorhus/safe-stringify/issues"},"dist":{"shasum":"f4240f506d041f58374d6106e2a5850f6b1ce576","tarball":"https://registry.npmjs.org/safe-stringify/-/safe-stringify-1.1.1.tgz","fileCount":5,"integrity":"sha512-YSzQLuwp06fuvJD1h6+vVNFYZoXmDs5UUNPUbTvQK7Ap+L0qD4Vp+sN434C+pdS3prVVlUfQdNeiEIgxox/kUQ==","signatures":[{"sig":"MEQCIE9P1nQLzHTi4SyYNtypLrU4Mh4h3fXRCD0UcSbBlO9tAiBb78ahLEBWWuwVa+k1DVEKf0E8u8lWAgN0raVqjArc2w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4731},"type":"module","types":"./index.d.ts","engines":{"node":">=16"},"exports":{"types":"./index.d.ts","default":"./index.js"},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"0a6cf54c667172c01d2fb8205354ac3ed06f7116","scripts":{"test":"xo && ava && tsd"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/safe-stringify.git","type":"git"},"_npmVersion":"10.6.0","description":"Serialize objects to JSON with handling for circular references","directories":{},"sideEffects":false,"_nodeVersion":"22.2.0","_hasShrinkwrap":false,"devDependencies":{"xo":"^0.58.0","ava":"^6.1.3","tsd":"^0.31.1"},"_npmOperationalInternal":{"tmp":"tmp/safe-stringify_1.1.1_1719148505765_0.9781362227733819","host":"s3://npm-registry-packages"}},"1.2.0":{"name":"safe-stringify","version":"1.2.0","keywords":["json","stringify","safe","circular","destroy","serialize","encode","cyclic","object"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"safe-stringify@1.2.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/safe-stringify#readme","bugs":{"url":"https://github.com/sindresorhus/safe-stringify/issues"},"dist":{"shasum":"d9f8122dc087774182123d45ba65c91fb8603770","tarball":"https://registry.npmjs.org/safe-stringify/-/safe-stringify-1.2.0.tgz","fileCount":5,"integrity":"sha512-C+LbapLbyGhP/WeMTrnYhIPjUoNTXZ/A3Znli8D5iF+IZXrDlgvfruykOq/bZ/5ncGy/K6RsavHlkirgWDFNdA==","signatures":[{"sig":"MEUCIB9yNTZYdVCm6wGi3lXfOp7ec1dVGbUoKJihxl1zUPflAiEAn0zh4nK8ccOoXnepqWJbOSCAGJ/k9zaFfjts6lmCGio=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":4741},"type":"module","types":"./index.d.ts","engines":{"node":">=16"},"exports":{"types":"./index.d.ts","default":"./index.js"},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"d0512ee503d6109ec6d48f145be51eeff86c7ee5","scripts":{"test":"xo && ava && tsd"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/safe-stringify.git","type":"git"},"_npmVersion":"10.9.2","description":"Serialize objects to JSON with handling for circular references","directories":{},"sideEffects":false,"_nodeVersion":"20.19.1","_hasShrinkwrap":false,"devDependencies":{"xo":"^0.58.0","ava":"^6.1.3","tsd":"^0.31.1"},"_npmOperationalInternal":{"tmp":"tmp/safe-stringify_1.2.0_1748607943631_0.4082747363852346","host":"s3://npm-registry-packages-npm-production"}},"1.3.0":{"name":"safe-stringify","version":"1.3.0","description":"Serialize objects to JSON with handling for circular references","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/safe-stringify.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=16"},"scripts":{"test":"xo && ava && tsd"},"keywords":["json","stringify","safe","circular","destroy","serialize","encode","cyclic","object"],"devDependencies":{"ava":"^6.1.3","tsd":"^0.31.1","xo":"^0.58.0"},"gitHead":"f28d20bfa94c97f481b715a3df272e1f0196c029","types":"./index.d.ts","_id":"safe-stringify@1.3.0","bugs":{"url":"https://github.com/sindresorhus/safe-stringify/issues"},"homepage":"https://github.com/sindresorhus/safe-stringify#readme","_nodeVersion":"25.3.0","_npmVersion":"11.7.0","dist":{"integrity":"sha512-gX28YjHEpEpgMeOFD4txJYhoQSNpRUK9AtY3X0R2XtG+AZBwubM5/O9+wKbhyWlTITGfQ3vifeuk/e1/FHWTIw==","shasum":"e162666bf29794281593a812e5c647101f669017","tarball":"https://registry.npmjs.org/safe-stringify/-/safe-stringify-1.3.0.tgz","fileCount":5,"unpackedSize":5699,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEJ4y5/t0iMgFXJqXQQkapwa4lc1jygGqHBClDmpVxBFAiEA77YNnoGUblQn4fxtJ4aYaEtaGfKNdzLBLT3KEor+S4g="}]},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/safe-stringify_1.3.0_1770044919927_0.1380745902610152"},"_hasShrinkwrap":false}},"time":{"created":"2016-07-13T23:59:05.951Z","modified":"2026-02-02T15:08:40.185Z","0.0.0":"2016-07-13T23:59:05.951Z","0.0.1":"2016-07-14T00:01:48.080Z","1.1.0":"2023-11-06T18:16:27.186Z","1.1.1":"2024-06-23T13:15:05.912Z","1.2.0":"2025-05-30T12:25:43.836Z","1.3.0":"2026-02-02T15:08:40.065Z"},"bugs":{"url":"https://github.com/sindresorhus/safe-stringify/issues"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"license":"MIT","homepage":"https://github.com/sindresorhus/safe-stringify#readme","keywords":["json","stringify","safe","circular","destroy","serialize","encode","cyclic","object"],"repository":{"type":"git","url":"git+https://github.com/sindresorhus/safe-stringify.git"},"description":"Serialize objects to JSON with handling for circular references","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"readme":"# safe-stringify\n\n> Serialize objects to JSON with handling for circular references\n\n`JSON.stringify()` throws an error if the object contains circular references. This package replaces circular references with `\"[Circular]\"`.\n\n## Install\n\n```sh\nnpm install safe-stringify\n```\n\n## Usage\n\n```js\nimport safeStringify from 'safe-stringify';\n\nconst foo = {a: true};\nfoo.b = foo;\n\nconsole.log(safeStringify(foo));\n//=> '{\"a\":true,\"b\":\"[Circular]\"}'\n\nconsole.log(JSON.stringify(foo));\n//=> TypeError: Converting circular structure to JSON\n\n```\n\n## API\n\n### safeStringify(value, options?)\n\nReturns a string.\n\n*Note: There is no `replacer` option as I didn't need that, but “pull request welcome” if you need it.*\n\n#### value\n\nType: `unknown`\n\nThe value to convert to a JSON string.\n\n#### options\n\nType: `object`\n\n##### indentation\n\nType: `'string' | 'number'`\n\nThe indentation of the JSON.\n\nBy default, the JSON is not indented. Set it to `'\\t'` for tab indentation or the number of spaces you want.\n\n##### trace\n\nType: `boolean`\n\nInclude the full object path in circular reference markers, like `[Circular *a.b]`.\n\n```js\nimport safeStringify from 'safe-stringify';\n\nconst bar = {a: {b: {}}};\nbar.a.b.c = bar.a;\n\nconsole.log(safeStringify(bar, {trace: true}));\n//=> '{\"a\":{\"b\":{\"c\":\"[Circular *a]\"}}}'\n```\n\n## FAQ\n\n### Why another safe stringify package?\n\nThe existing ones either did too much, did it incorrectly, or used inefficient code (not using `WeakSet`). For example, many packages incorrectly replaced all duplicate objects, not just circular references, and did not handle circular arrays.\n\n## Related\n\n- [decircular](https://github.com/sindresorhus/decircular) - Remove circular references from objects\n","readmeFilename":"readme.md"}