NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm
npm, #941 most downloaded on npm
Deterministic and safely JSON.stringify to quickly serialize JavaScript objects
Latest stable
3.0.1
Last release 11 days ago
10 Nov 2026
Release timing varies
gaps range from 2 weeks to 2.1 years
Nearly every release is documented
notes for 14 of 15 stable releases
Nothing withdrawn
no release was ever pulled
9 years old
15 releases · first in 2018
Drag across the ruler to compare, or tap a release to open it.
Apply bigint: false and strict mode to BigInt typed-array entries.
This allows to partially inspect such objects. The default is false to prevent any breaking change.
'[Circular: N]', where N is the referenced ancestor's depth, starting at 0 for the root.
Set circularValue: '[Circular]' to retain the previous format. This changes the serialized output for circular references.'string' as possible bigint option value. Bigint values are serialized as JSON strings using it.import { configure } from 'safe-stable-stringify'
const stringify = configure({
bigint: 'string'
})
stringify([1n, 2, 3n, 4, 5n])
// '["1",2,"3",4,"5"]'
safe option to not fail in case a getter, .toJSON(), or a replacer throws an error.
Instead, a string as error message is replacing the object inspection. This allows to partially inspect such objects.
The default is false to prevent any breaking change.import { configure } from 'safe-stable-stringify'
const stringify = configure({
safe: true
})
stringify([{
foo: { a: 5, get foo() { throw new Error('Oops') }, c: true }
}])
// '[{"foo":"Error: Stringification failed. Message: Oops"}]'
stringify([{
foo: { a: 5, toJSON() { throw new Error('Oops') }, c: true }
}])
// '[{"foo":"Error: Stringification failed. Message: Oops"}]'
maximumBreadth option. It showed one entry to few being skipped.Your coding agent can read these notes before it upgrades. Set up the MCP server →
Accept Array#sort(comparator) comparator method as deterministic option value to use that comparator for sorting object keys.
Array#sort(comparator) comparator method as deterministic option value to use that comparator for sorting object keys.import { configure } from 'safe-stable-stringify'
const object = {
a: 1,
b: 2,
c: 3,
}
const stringify = configure({
deterministic: (a, b) => b.localeCompare(a)
})
stringify(object)
// '{"c": 3,"b":2,"a":1}'
Thanks to @flobernd, @cesco69 and @prisis to contribute to this release!
Fixed toJSON function receiving array keys as number instead of string
More precise TypeScript replacer type.
More precise TypeScript types. The return type is now either string, undefined or string | undefined depending on the input.
string, undefined or string | undefined depending on the input.Added strict option to verify that the passed in objects are fully compatible with JSON without removing information. If not, an error is thrown.
strict option to verify that the passed in objects are fully compatible with JSON without removing information. If not, an error is thrown.Fix invalid regexp group error in browsers or environments that do not support the negative lookbehind regular expression assertion.
Accept the Error constructor as circularValue option to throw on circular references as the regular JSON.stringify would:
Error constructor as circularValue option to throw on circular references as the regular JSON.stringify would:import { configure } from 'safe-stable-stringify'
const object = {}
object.circular = object;
const stringify = configure({ circularValue: TypeError })
stringify(object)
// TypeError: Converting circular structure to JSON
Reduce module size by removing the test and benchmark files from the published package
undefined as circularValue option to remove circular properties from the serialized output:import { configure } from 'safe-stable-stringify'
const object = { array: [] }
object.circular = object;
object.array.push(object)
configure({ circularValue: undefined })(object)
// '{"array":[null]}'
Added maximumBreadth option to limit stringification at a specific object or array "width" (number of properties / values)
maximumBreadth option to limit stringification at a specific object or array "width" (number of properties / values)maximumDepth option to limit stringification at a specific nesting depth__[BREAKING]__ Convert BigInt to number by default instead of ignoring these values If you wish to ignore these values similar to earlier versions, ju
bigint option and set it to false.Fixed an indentation issue in combination with empty arrays and objects
Fix issue with undefined values (4196f87f16e95c711d1776102d6cc73f1c384431, 4eab558c2ddbf24adb5776e4fc1091aa8673b703)
undefined values (4196f87f16e95c711d1776102d6cc73f1c384431, 4eab558c2ddbf24adb5776e4fc1091aa8673b703)Nothing published for this version
One column per quarter.