JavaScript structuredClone() Function
The structuredClone() function makes a deep copy of a value, including nested objects, arrays, dates, maps and sets.
Description
The structuredClone() function creates a deep copy of a value using the structured clone algorithm, the same one used to send data to web workers. Nested objects and arrays are copied rather than shared, and it supports types that JSON can't handle, such as Date, Map, Set, typed arrays and circular references.
It can't copy functions, DOM nodes or class instances' prototypes (they become plain objects), and throws a DataCloneError for unsupported values. It's provided by browsers and Node.js rather than by the JavaScript language itself.
Clones can also transfer objects such as ArrayBuffers with the transfer option, moving them into the copy instead of duplicating them, which is faster for large binary data. Getters aren't preserved: their current values are copied as plain properties. For simple JSON-compatible data, JSON.parse(JSON.stringify(x)) also works, but structuredClone() is clearer and handles more types.
Syntax
structuredClone(value)
structuredClone(value, { transfer })Parameters
- valueThe value to copy.
- transferOptional. An array of transferable objects, such as ArrayBuffers, to move rather than copy.
Return Value
A deep copy of the value.
Exceptions
- DataCloneErrorThrown if the value contains something that can't be cloned, such as a function.
Example
Browser Support
The following information will show you the current browser support for the structuredClone() function. Hover over a browser icon to see the version that first introduced support for this function.
Desktop





Tablets & Mobile





