You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 22, 2026. It is now read-only.
Reproducible benchmarks comparing jsondelta against popular JSON diff libraries.
Run it yourself
git clone https://github.com/jsondelta/bench.git
cd bench
npm install
npm run bench
Results
All benchmarks run on Apple M1 Max, Node.js v22.15.1. Each scenario diffs two JSON documents where ~10% of values have been mutated. Higher ops/sec is better.
Diff
Small flat object (10 keys)
Library
ops/sec
avg time
vs fastest
fast-json-patch
4.02M
262ns
@jsondelta/diff (fallback)
1.81M
582ns
2.2x slower
jsondiffpatch
1.66M
628ns
2.4x slower
deep-diff
1.22M
850ns
3.3x slower
@jsondelta/diff (wasm)
149.48K
6.8us
26.9x slower
Medium flat object (100 keys)
Library
ops/sec
avg time
vs fastest
fast-json-patch
203.55K
5.0us
@jsondelta/diff (fallback)
148.46K
7.0us
1.4x slower
jsondiffpatch
132.83K
7.8us
1.5x slower
deep-diff
100.71K
10.2us
2.0x slower
@jsondelta/diff (wasm)
18.60K
54.3us
10.9x slower
Large flat object (1000 keys)
Library
ops/sec
avg time
vs fastest
fast-json-patch
22.11K
46.1us
@jsondelta/diff (fallback)
11.68K
89.0us
1.9x slower
jsondiffpatch
10.52K
97.4us
2.1x slower
deep-diff
3.66K
277.0us
6.0x slower
@jsondelta/diff (wasm)
1.78K
564.8us
12.4x slower
Nested object (5w x 3d, 155 nodes)
Library
ops/sec
avg time
vs fastest
fast-json-patch
261.37K
4.0us
@jsondelta/diff (fallback)
130.20K
8.1us
2.0x slower
deep-diff
108.43K
9.7us
2.4x slower
jsondiffpatch
79.68K
12.9us
3.3x slower
@jsondelta/diff (wasm)
15.00K
67.3us
17.4x slower
Deep nested object (3w x 6d, 1092 nodes)
Library
ops/sec
avg time
vs fastest
fast-json-patch
34.16K
30.2us
@jsondelta/diff (fallback)
16.26K
64.5us
2.1x slower
deep-diff
11.89K
86.5us
2.9x slower
jsondiffpatch
9.71K
105.8us
3.5x slower
@jsondelta/diff (wasm)
2.21K
453.8us
15.5x slower
Array of objects (100 items)
Library
ops/sec
avg time
vs fastest
fast-json-patch
99.44K
10.4us
@jsondelta/diff (fallback)
62.55K
16.9us
1.6x slower
deep-diff
37.57K
28.2us
2.6x slower
jsondiffpatch
21.92K
47.7us
4.5x slower
@jsondelta/diff (wasm)
7.01K
143.3us
14.2x slower
Array of objects (1000 items)
Library
ops/sec
avg time
vs fastest
fast-json-patch
10.09K
101.0us
@jsondelta/diff (fallback)
6.01K
171.3us
1.7x slower
deep-diff
3.82K
266.0us
2.6x slower
jsondiffpatch
1.01K
996.6us
9.9x slower
@jsondelta/diff (wasm)
722
1.39ms
14.0x slower
Patch
Small flat object (10 keys)
Library
ops/sec
avg time
vs fastest
fast-json-patch
1.29M
793ns
@jsondelta/patch (fallback)
413.15K
2.5us
3.1x slower
@jsondelta/patch (wasm)
119.44K
24.6us
10.8x slower
Medium flat object (100 keys)
Library
ops/sec
avg time
vs fastest
fast-json-patch
115.00K
8.8us
@jsondelta/patch (fallback)
36.80K
27.8us
3.1x slower
@jsondelta/patch (wasm)
8.88K
241.7us
12.9x slower
Large flat object (1000 keys)
Library
ops/sec
avg time
vs fastest
fast-json-patch
6.38K
157.9us
@jsondelta/patch (fallback)
3.57K
281.7us
1.8x slower
@jsondelta/patch (wasm)
411
2.56ms
15.5x slower
Nested object (5w x 3d, 155 nodes)
Library
ops/sec
avg time
vs fastest
fast-json-patch
126.50K
8.0us
@jsondelta/patch (fallback)
91.83K
11.0us
1.4x slower
@jsondelta/patch (wasm)
11.00K
211.3us
11.5x slower
Analysis
The wasm engine is slower than pure JS across all scenarios. The bottleneck is the JSON serialization boundary: every call requires JSON.stringify on the JS side, memory copy into wasm, json.parseFromSlice in Zig, computation, json.Stringify back to bytes, memory copy out, and JSON.parse on the JS side. This overhead dominates the actual diff/patch computation, especially for small-to-medium documents.
The JS fallback is competitive. It consistently beats deep-diff and jsondiffpatch, placing 2nd behind fast-json-patch. V8's JIT compiler is remarkably good at optimizing the recursive tree-walk pattern.
fast-json-patch is the fastest. It benefits from a simpler output format (RFC 6902 patches without original values) and mature optimization. Its diff output is not reversible - it doesn't include old values on replace ops or value on remove ops - which makes it faster but less capable.
Why jsondelta's format is richer
jsondelta's delta format is designed for reversibility. Every operation includes enough information to undo it:
remove ops include the removed value
replace ops include both old and new
This enables @jsondelta/patch's invert() function and makes the format suitable for undo/redo, audit logging, and conflict detection in @jsondelta/merge. fast-json-patch's format cannot support these use cases without additional bookkeeping.
Path forward for performance
The wasm engine needs a fundamentally different approach to be competitive:
Native addon (napi-rs) - eliminates the serialization boundary entirely. The Zig engine would read V8 values directly via N-API, avoiding JSON round-trips
Streaming/incremental API - for very large documents, avoid parsing the entire document upfront
SIMD byte-level comparison - skip structural diffing entirely when byte sequences match
The current wasm approach only makes sense for documents large enough that computation time dwarfs serialization overhead - likely 1MB+ documents, which are uncommon in practice.
License
MIT
About
Benchmark suite for jsondelta vs popular JSON diff libraries