October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

structuredClone() vs JSON.stringify(): Which One Should You Use?

Use structuredClone() for deep copies of supported JavaScript data; use JSON.stringify() when you need JSON text. The stringify/parse cloning trick is lossy and fails on cycles.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use structuredClone(value) to make a deep copy of supported JavaScript data. Use JSON.stringify(value) when you need JSON text for storage or exchange. The common JSON.parse(JSON.stringify(value)) trick is not a general-purpose clone: it can change or omit values and fails on circular references.

Choose by what you need the result to do

Your goal or data Better fit Reason
Deep-copy supported in-memory data, including circular references structuredClone() It handles cycles and returns a deep copy of supported values. MDN explains the structured clone algorithm.
Keep values such as Date, Map, or Set structuredClone() These types are supported by the algorithm. MDN lists supported values.
Produce text in JSON format for storage or exchange JSON.stringify() It converts a JavaScript value to JSON text; that text is the useful output. MDN documents JSON.stringify().
Clone data containing functions, DOM nodes, or custom object behavior that must remain intact Neither as a faithful, general-purpose clone Structured cloning rejects some values and does not preserve some object semantics; JSON omits or converts certain values.
Hand off supported transferable data rather than keep a usable original structuredClone(value, { transfer }) Transfer changes ownership behavior: transferred objects are no longer usable through the original reference. The HTML Standard describes transfer semantics.
Run in a specific older browser, embedded web view, or runtime Check that environment first Support in current major browsers does not guarantee support in every deployment target.

What structuredClone() copies—and what it does not

structuredClone(value) uses the structured clone algorithm to serialize and deserialize supported JavaScript and platform data. It is designed to make a deep copy, rather than produce a JSON representation. It can handle circular references and common built-in types including Date, Map, Set, ArrayBuffer, and typed arrays. The HTML Standard defines the algorithm and API; MDN documents supported values and limitations.

As an Amazon Associate I earn from qualifying purchases.

Cycles work

The algorithm tracks references it has already visited. That lets it preserve a circular relationship in the copied object graph instead of failing when it encounters a reference back to an earlier object.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Unsupported values and lost semantics

  • Functions and DOM nodes cannot be cloned; attempting to clone them causes a DataCloneError.
  • Custom prototypes are not copied, so a cloned object is not guaranteed to retain the original object’s class or custom behavior.
  • Property descriptors, getters, and setters are not preserved as such.
  • A regular expression’s lastIndex is not preserved.

So “deep clone” does not mean “recreate every detail of every JavaScript object.” If your code depends on custom methods, property accessors, or other object metadata, structured cloning may not be a drop-in replacement.

Transfer is a handoff, not an ordinary copy

The optional transfer setting transfers supported transferable objects instead of leaving the source object usable alongside a copy. After transfer, the original transferred object is no longer usable. Use it when that ownership change is intentional, not as a performance tweak to an otherwise ordinary clone. The HTML Standard describes the transfer behavior.

What JSON.stringify() does to JavaScript values

JSON.stringify(value) produces JSON text. That makes it appropriate when text in JSON format is what you want to store or exchange. It does not, by itself, return a deep copy of the original JavaScript value. MDN documents its conversion behavior.

Why stringify-then-parse is lossy

JSON.parse(JSON.stringify(value)) serializes the value and then parses the resulting text into a new value. The round trip can keep only what the JSON conversion represents:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Object properties whose values are undefined, functions, or symbols are omitted.
  • Those values in arrays become null.
  • Serializing a BigInt throws unless custom serialization behavior is supplied.
  • Circular references cause a TypeError, because JSON does not represent object-reference cycles.

These behaviors are documented in MDN’s JSON.stringify() reference. A successful round trip therefore does not prove that the original value was faithfully cloned.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check support in your target environment

The current WHATWG HTML Standard index search result lists Chrome 98+, Firefox 94+, Safari 15.4+, and Edge 98+ for structuredClone(). Treat these as reference thresholds, not a guarantee for every browser version, embedded web view, or JavaScript runtime. Confirm support in the actual environments your application targets.

A practical decision rule

  1. Need JSON text? Use JSON.stringify() and account for how its conversion handles your values.
  2. Need a deep copy of supported in-memory data? Use structuredClone(value), after checking that the data and required object semantics are supported.
  3. Need a faithful copy of functions, DOM nodes, custom prototypes, or descriptors? Neither API is a universal solution; choose an approach designed around those specific requirements.
  4. Need to transfer ownership? Use the transfer option only when the original transferred object becoming unusable is intended.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.