Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
JSON.stringify vs structuredClone vs custom
(version: 1)
JSON.stringify vs structuredClone
Comparing performance of:
JSON.stringify vs structuredClone vs deepClone
Created:
one year ago
by:
Guest
Go to the latest result
Script Preparation code:
var MyObject = { description: 'Creates a deep copy of source, which should be an object or an array.', myNumber: 123456789, myBoolean: true, jayson: { stringify: 'JSON.stringify() method converts a JavaScript value to a JSON string....', parse: 'JSON.parse() method parses a JSON string...' } }; var myCopy = null; function deepClone(obj) { if (obj === null || typeof obj !== "object") return obj; const copy = Array.isArray(obj) ? [] : {}; for (const key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { copy[key] = deepClone(obj[key]); } } return copy; }
Tests:
JSON.stringify
myCopy = JSON.parse(JSON.stringify(MyObject));
structuredClone
myCopy = structuredClone(MyObject);
deepClone
myCopy = deepClone(MyObject);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
JSON.stringify
structuredClone
deepClone
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:141.0) Gecko/20100101 Firefox/141.0
Browser/OS:
Firefox 141 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
deepClone
6.9M/s
structuredClone
1.4M/s
JSON.stringify
1.3M/s
View exact numbers
Test name
Executions per second
✓
deepClone
6,888,242 Ops/sec
structuredClone
1,438,812 Ops/sec
JSON.stringify
1,342,952 Ops/sec
Related benchmarks
Lodash cloneDeep vs JSON Clone vs fastDeepClone
JSON.stringify + JSON.parse vs structuredClone vs fast_deep_clone (recursive)
Lodash cloneDeep vs structuredClone vs JSON Parse vs JSON indirect parse vs in-house deepcopy
Lodash cloneDeep vs structuredClone vs Custom Implementation
Comments
Confirm delete:
Do you really want to delete benchmark?