npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

structured-clone-es

v2.0.0

Published

An env-agnostic serializer and deserializer with recursion ability and types beyond JSON, based on the HTML structured clone algorithm.

Readme

structured-clone-es

npm version npm downloads bundle JSDocs License

An env-agnostic serializer and deserializer with recursion ability and types beyond JSON, based on the HTML structured clone algorithm.

Ported from @ungap/structured-clone by Andrea Giammarchi, with TypeScript support and modern ESM packaging.

[!NOTE] If you are targeting modern environments, the native structuredClone() is available in all major browsers and Node.js 17+. Use it directly for better performance.

The main value of this package is the serialize / deserialize and stringify / parse utilities, which allow you to convert complex and recursive objects into JSON-safe representations — useful for sending structured data across processes or over the network (e.g. client-server RPC communication).

Used by Nuxt DevTools, Vite DevTools, Node Modules Inspector, ESLint Config Inspector, and more.

Install

npm i structured-clone-es

Usage

Serialize / Deserialize

The result of serialize can be safely stringified as JSON, even if the original data contains recursive references, BigInt values, typed arrays, and so on.

import { deserialize, serialize } from 'structured-clone-es'

// serialize any value into a JSON-compatible array of records
const serialized = serialize({ any: 'serializable' })

// reconstruct the original object
const deserialized = deserialize(serialized)

Stringify / Parse

A convenience wrapper that combines serialize + JSON.stringify and JSON.parse + deserialize:

import { parse, stringify } from 'structured-clone-es'

const str = stringify({ any: 'serializable' })
const obj = parse(str)

structuredClone

A pure structuredClone implementation is also exported. It always uses the serialize/deserialize path without relying on the runtime's native structuredClone.

import { structuredClone } from 'structured-clone-es'

const cloned = structuredClone({ any: 'serializable' })

If you need polyfill globalThis.structuredClone, you can attach it manually:

import { structuredClone } from 'structured-clone-es'

if (!('structuredClone' in globalThis)) {
  globalThis.structuredClone = structuredClone
}

Supported Types

  • Primitives: string, number, boolean, null, undefined, BigInt
  • Collections: Array, Object, Map, Set
  • Typed Arrays: Uint8Array, Uint16Array, Uint32Array, Int8Array, Int16Array, Int32Array, ArrayBuffer, DataView
  • Date, RegExp, Error
  • Boxed primitives: Boolean, Number, String
  • Circular / recursive references

See the MDN documentation for the full structured clone algorithm spec. Note that browser-specific types (Blob, File, ImageBitmap, etc.) are not supported by this library.

Lossy Mode

By default, serialize throws on incompatible types like function or symbol. Use the lossy option to silently replace them with null instead:

import { structuredClone } from 'structured-clone-es'

const cloned = structuredClone(
  {
    method() { /* ignored */ },
    special: Symbol('also ignored'),
  },
  { lossy: true },
)

JSON Mode

The json option implies lossy and additionally checks for toJSON() methods on objects:

import { structuredClone } from 'structured-clone-es'

const cloned = structuredClone(
  {
    date: {
      toJSON() {
        return '2024-01-01'
      },
    },
  },
  { json: true },
)

The stringify / parse exports use both json and lossy by default.

Credits

This project is a TypeScript port of @ungap/structured-clone, originally created by Andrea Giammarchi under the ISC license.

License

ISC