
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
fast-safe-stringify
Advanced tools
Safely and quickly serialize JavaScript objects
Detects circular dependencies instead of throwing
(as per usual JSON.stringify usage)
var safeStringify = require('fast-safe-stringify')
var o = {a: 1}
o.o = o
console.log(safeStringify(o))
console.log(JSON.stringify(o)) //<-- throws
The json-stringify-safe module supplies similar functionality with more info and flexibility.
Although not JSON, the core util.inspect method can be used for similar purposes (e.g. logging) and also handles circular references.
Here we compare fast-safe-stringify with these alternatives:
inspectBench*10000: 132.456ms
jsonStringifySafeBench*10000: 67.382ms
fastSafeStringifyBench*10000: 31.672ms
inspectDeepBench*10000: 1632.687ms
jsonStringifySafeDeepBench*10000: 1062.449ms
fastSafeStringifyDeepBench*10000: 177.926ms
fast-safe-stringify is 2x faster for small objects,
and 6x faster for large objects than json-stringify-safe.
fast-safe-stringify is 4x faster for small objects,
and 9x faster for large objects than util.inspect.
Sponsored by nearForm
MIT
Similar to fast-safe-stringify, json-stringify-safe provides a way to safely serialize objects into JSON strings, handling circular references by replacing them with a custom string. It's a bit slower compared to fast-safe-stringify but serves a similar purpose.
Flatted is a package that serializes and deserializes JavaScript objects, including nested and circular references. Unlike fast-safe-stringify, which returns a JSON string, Flatted returns a flattened string representation that can be re-parsed into the original object structure, including circular references.
FAQs
Safely and quickly serialize JavaScript objects
The npm package fast-safe-stringify receives a total of 18,202,353 weekly downloads. As such, fast-safe-stringify popularity was classified as popular.
We found that fast-safe-stringify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.