Stable
Compatible deterministic output for cache keys, snapshots, deduplication, and reproducible builds.
stringify(value, options)
One serializer. Three contracts.
Deterministic JSON for cache keys, safe output for diagnostics, and RFC 8785 canonical bytes for signatures.
npm install @stackline/stable-stringify
v1.0.2 Zero runtime dependencies Node 14.17+
Production bundle
Lowest-change adoption
Use an npm alias to preserve the established package name and function signature while gaining the maintained distribution.
npm install fast-json-stable-stringify@npm:@stackline/stable-stringify
import stringify from 'fast-json-stable-stringify';
const key = stringify({ z: 1, a: 2 });
Purpose-built policies
Compatible deterministic output for cache keys, snapshots, deduplication, and reproducible builds.
stringify(value, options)
Bounded cycle and BigInt handling for logs, diagnostics, and failure paths that must remain observable.
safeStringify(value)
Strict RFC 8785 strings and UTF-8 bytes for signatures, hashes, and cross-system verification.
canonicalizeBytes(value)
Public contract
| Export | Purpose | Failure behavior |
|---|---|---|
stableStringify(value, options?) | Deterministic JSON | Compatible throws and omission |
safeStringify(value, replacer?, space?, options?) | Bounded diagnostics | Controlled fallback by default |
canonicalize(value, options?) | RFC 8785 string | Rejects non-I-JSON input |
canonicalizeBytes(value, options?) | Canonical UTF-8 bytes | Rejects non-I-JSON input |
configure(defaults?) | Reusable stable serializer | Validates options immediately |
Release evidence