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

npmnpm install superjson

Methods

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.

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.