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)

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

structuredClone(value, options)

Parameters

ParameterDescription
value The value to copy.
options optional { transfer } for transferable objects.

Return value

A deep copy.

Examples

A real deep copyTry it yourself
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
Limits, and why JSON copies lose typesTry it yourself
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

VersionChange
JavaScript HTML (2022)Added

Was this page helpful?