IT lexicon › Web › Structured clone

Structured clone

Web På svenska → Updated: 2026-05-30

An algorithm (and the function structuredClone()) for making a true deep copy of complex JavaScript values — including Map, Set, Date, ArrayBuffer, and circular references. The same mechanism used when data is sent between tabs, workers, and via IndexedDB.

Problem: JSON.parse(JSON.stringify(obj)) was long the common deep-copy hack, but it loses a lot: Map/Set become empty objects, Date becomes a string, undefined and functions disappear, and circular references crash. The structured clone algorithm handles all of this correctly. Since 2022 it's exposed directly as the global function structuredClone(value) → simple, correct deep copying without a library. The same algorithm is under the hood when you postMessage data to a web worker or another tab (the data is cloned, not shared), and when objects are stored in IndexedDB. Limitation: it can't clone functions, DOM nodes, or prototype chains. A small but welcome addition to the platform. Related to broadcast channel and web workers.

← Back to the lexicon