One serializer. Three contracts.

@stackline/stable-stringify

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

Serialization playground

Mode

Input

JSON + playground tags

Output


            
Ready 0.000 ms 0 characters Stable

Lowest-change adoption

Keep existing imports

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

Choose the contract at the call site

01

Stable

Compatible deterministic output for cache keys, snapshots, deduplication, and reproducible builds.

stringify(value, options)
02

Safe

Bounded cycle and BigInt handling for logs, diagnostics, and failure paths that must remain observable.

safeStringify(value)
03

Canonical

Strict RFC 8785 strings and UTF-8 bytes for signatures, hashes, and cross-system verification.

canonicalizeBytes(value)

Public contract

Small surface, explicit behavior

Full reference
ExportPurposeFailure behavior
stableStringify(value, options?)Deterministic JSONCompatible throws and omission
safeStringify(value, replacer?, space?, options?)Bounded diagnosticsControlled fallback by default
canonicalize(value, options?)RFC 8785 stringRejects non-I-JSON input
canonicalizeBytes(value, options?)Canonical UTF-8 bytesRejects non-I-JSON input
configure(defaults?)Reusable stable serializerValidates options immediately

Release evidence

Compatibility is executable

30,000
differential reference serializations
100%
statement, line, and function coverage
25,000
nested levels in the stack-safety regression
3.9-7.0
TypeScript compatibility matrix
<12 KB
minified browser bundle before compression
0
runtime dependencies