JSON deepcopy vs structuredClone

Benchmark created on


Setup

const original = {
  id: 12345,
  name: "Devils Advocate",
  roles: ["admin", "editor", "user"],
  metadata: {
    lastLogin: "2025-01-01T12:00:00Z",
    preferences: {
      theme: "dark",
      notifications: true,
      retention: 90
    }
  },
  tags: Array.from({ length: 50 }, (_, i) => `tag-${i}`)
};

Test runner

Ready to run.

Testing in
TestOps/sec
JSON Hack
const copy = JSON.parse(JSON.stringify(original));
ready
structuredClone
const copy = structuredClone(original);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.