Blog post
JSON Deep Copy: All Methods Compared
Compare all JavaScript deep copy methods: JSON.parse/stringify, structuredClone, Lodash cloneDeep, and recursive approaches.
Shashank Jain
Author


Article
The Deep Copy Problem
In JavaScript, objects are passed by reference. Assigning an object copies the reference, not the value. Deep copying creates a completely independent clone with no shared references.
Method 1: JSON.parse + JSON.stringify
const clone = JSON.parse(JSON.stringify(original));Pros: No dependencies, fast for plain data.
Cons: Loses undefined, functions, Date objects (become strings), RegExp, Map, Set, BigInt. Throws on circular references.
Method 2: structuredClone (Modern)
const clone = structuredClone(original);Pros: Built-in, handles Date, Map, Set, ArrayBuffer, circular references. No dependencies.
Cons: Drops functions and prototypes. Requires Node.js 17+ or modern browsers.
Method 3: Lodash cloneDeep
const _ = require('lodash');
const clone = _.cloneDeep(original);Pros: Handles virtually everything including custom class instances.
Cons: Adds lodash as a dependency.
Comparison Table
| Method | Dates | Functions | Map/Set | Circular |
|---|---|---|---|---|
| JSON parse/stringify | String | Dropped | Dropped | Throws |
| structuredClone | Cloned | Throws | Cloned | Handled |
| Lodash cloneDeep | Cloned | Cloned | Cloned | Handled |
FAQ
When should I use JSON.parse/stringify for cloning?
When your data is plain JSON-serializable (no Dates, Maps, or functions) — it is the simplest and fastest option. Common for cloning API responses, Redux state snapshots, or config objects.
Is structuredClone available in all browsers?
As of 2022: Chrome 98+, Firefox 94+, Safari 15.4+, Node.js 17+. Polyfill with core-js for older environments.
What is the fastest deep clone for large objects?
JSON.parse/JSON.stringify is often fastest for large plain objects. structuredClone is close. Benchmark your specific data shape.
Can I deep clone class instances?
Only Lodash cloneDeep or a custom recursive function preserves prototype methods. structuredClone and JSON both lose class methods.
How do I detect circular references?
Try JSON.stringify in a try/catch — it throws if circular references exist.
Keep reading
Recent blogs

Jun 14, 2026
JSON in C#: System.Text.Json and Newtonsoft Complete Guide
Serialize and deserialize JSON in C# using System.Text.Json and Newtonsoft.Json with practical examples.

Jun 14, 2026
JSON to Markdown Table: Convert JSON Arrays Instantly
Convert JSON arrays to Markdown tables in JavaScript, Python, and with the free online tool.

Jun 14, 2026
JSON in TypeScript: Type-Safe Parsing and Validation
Stop using any for JSON in TypeScript — use Zod, type guards, and generics for fully type-safe parsing.