API Reference
SuperJSON
Serialize values JSON loses, such as Date, Map, Set, BigInt, RegExp, and undefined, then restore them intact.
Official Documentation ↗CompatibilityThis documentation covers version
v2.2. Check the official docs for the latest API surface.Installation
npm
npm install superjsonMethods
No methods match this filter.
SuperJSON wraps a value in a json plus meta envelope that records the paths needing special deserialization.
Key Features
- Round-trips Date, Map, Set, BigInt, RegExp, and undefined
- Custom transformers for user classes
- Default transformer in tRPC
Usage Notes
Pin a version and check the official docs for the API surface you depend on before upgrading.
API reference evidence
Fetched from official sources on 2026-11-08T09:53:13.312Z via WebFetch https://unpkg.com/[email protected]/dist/index.d.ts.
serialize→ signature from https://unpkg.com/[email protected]/dist/index.d.ts; official text: “serialize(object: SuperJSONValue): SuperJSONResult;”deserialize→ signature from https://unpkg.com/[email protected]/dist/index.d.ts; official text: “deserialize<T = unknown>(payload: SuperJSONResult, options?: { inPlace?: boolean; }): T;”registerCustom→ signature from https://unpkg.com/[email protected]/dist/index.d.ts; official text: “registerCustom<I, O extends JSONValue>(transformer: Omit<CustomTransfomer<I, O>, ‘name’>, name: string): void;”
FAQ
- How does SuperJSON encode types?
- It wraps the value as { json, meta }, where meta lists paths needing special deserialization. The json part stays plain JSON.
- Does it work with tRPC?
- Yes. tRPC uses SuperJSON as its default transformer, which is why Date and Map survive the wire in tRPC procedures.
- What is the payload overhead?
- Small for scalars and proportional to the number of special values, because every non-plain value stores an index path in meta.
Report a problem with this API docOpens a pre-filled issue on GitHub.