JavaScript (ES2026) reference · JSON and Global Functions
JavaScript structuredClone() Function
Create a deep copy of a value, including nested objects, arrays, Dates, Maps and Sets. Functions can't be cloned.
JavaScript (ES2026) Since HTML (2022)
Syntax
structuredClone(value, options)
Parameters
| Parameter | Description |
|---|---|
value |
The value to copy. |
options optional |
{ transfer } for transferable objects. |
Return value
A deep copy.
Examples
const original = { user: { name: "Ada" }, tags: new Set(["a"]), at: new Date(0) };
const copy = structuredClone(original);
copy.user.name = "Grace";
console.log(original.user.name, copy.tags instanceof Set, copy.at instanceof Date);
Output
Ada true true
try {
structuredClone({ fn() {} });
} catch (e) {
console.log(e.name);
}
const viaJson = JSON.parse(JSON.stringify({ at: new Date(0) }));
console.log(typeof viaJson.at);
Output
DataCloneError string
structuredClone() comes from the HTML standard rather than ECMAScript, and is available in all current
browsers, Node.js (17+), Deno and Bun.
Version history
| Version | Change |
|---|---|
| JavaScript HTML (2022) | Added |
Related
JSON.parse()· Turn a JSON string into a JavaScript value. Throws SyntaxError on invalid JSON; an optional reviver transforms values.JSON.stringify()· Convert a JavaScript value to a JSON string, optionally filtering keys and pretty-printing with indentation.- JavaScript Objects · tutorial