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:
9 months ago
by:
Guest
Jump 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:
9 months 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
Test name
Executions per second
JSON.stringify
1342952.1 Ops/sec
structuredClone
1438811.8 Ops/sec
deepClone
6888242.0 Ops/sec
Related benchmarks:
Lodash cloneDeep vs JSON Clone vs fastDeepClone
Lodash isEqual vs JSON stringify kshitij
deepclone vs deepfreeze
lodash clonedeep vs json.parse(stringify()) 666
JSON.stringify + JSON.parse vs structuredClone vs fast_deep_clone (recursive)
DeepFreeze vs Lodash cloneDeep vs JSON Clone
Lodash cloneDeep vs structuredClone vs JSON Parse vs JSON indirect parse vs in-house deepcopy
Lodash cloneDeep vs structuredClone vs Custom Implementation
Lodash isEqual vs JSON stringify2
Comments
Confirm delete:
Do you really want to delete benchmark?