Skip to Content
DocumentationPerformance

Performance

CodableJSON delivers superior performance compared to alternatives while providing a more developer-friendly API.

Benchmark vs SuperJSON

You can run these benchmarks yourself by downloading the repository and running yarn codablejson bench. The benchmark code is available in benchmark.bench.ts.

Plain JSON Data (6MB)

OperationPreserve refsCopy refs
Encode🟢 3.68x faster than SuperJSON🟢 6.85x faster than SuperJSON
Decode🟢 1.29x faster than SuperJSON🟢 1.28x faster than SuperJSON

Complex Data Structures

It includes deeply nested objects, with repeating references, Sets, Maps, and Dates

DatasetEncodeDecode
Preserve refsCopy refsPreserve refsCopy refs
Small🟢 3.89x faster🟢 6.98x faster🟢 1.68x faster🟢 1.66x faster
Average🟢 4.20x faster🟢 5.06x faster🟢 1.16x faster🟢 1.05x faster
Large🟢 4.01x faster🟢 7.54x faster🟢 1.19x faster🟢 1.83x faster
Huge🟢 4.08x faster🟢 6.43x faster🟢 1.31x faster🟢 2.37x faster

Benchmark was run on a MacBook Pro M3 Max with 128GB of RAM.

See raw benchmark results

tests/benchmark.bench.ts > benchmark > plain json > encode - 6mb 536ms name hz min max mean p75 p99 p995 p999 rme samples · codablejson 141.32 5.8634 8.0289 7.0763 7.7076 8.0289 8.0289 8.0289 ±5.96% 15 · superjson 38.4136 25.6165 26.3393 26.0325 26.0943 26.3393 26.3393 26.3393 ±1.84% 4 tests/benchmark.bench.ts > benchmark > plain json > decode - 6mb 442ms name hz min max mean p75 p99 p995 p999 rme samples · codablejson 241.27 3.8788 4.4581 4.1447 4.2970 4.4581 4.4581 4.4581 ±1.77% 25 · superjson 187.22 4.8906 5.5359 5.3414 5.4529 5.5359 5.5359 5.5359 ±1.50% 19 tests/benchmark.bench.ts > benchmark > plain json > encode - 6mb (no preserve refs) 558ms name hz min max mean p75 p99 p995 p999 rme samples · codablejson 187.33 4.5381 6.1755 5.3381 5.7754 6.1755 6.1755 6.1755 ±5.23% 19 · superjson 27.3290 25.9383 65.7288 36.5912 28.6778 65.7288 65.7288 65.7288 ±84.64% 4 tests/benchmark.bench.ts > benchmark > plain json > decode - 6mb (no preserve refs) 431ms name hz min max mean p75 p99 p995 p999 rme samples · codablejson 241.86 3.9113 4.3932 4.1346 4.2824 4.3932 4.3932 4.3932 ±1.68% 25 · superjson 189.36 4.8939 5.4525 5.2810 5.3857 5.4525 5.4525 5.4525 ±1.35% 19 tests/benchmark.bench.ts > benchmark > complex data > encode - small 406ms name hz min max mean p75 p99 p995 p999 rme samples · codablejson 21,234.54 0.0377 1.3792 0.0471 0.0425 0.0540 0.8579 1.0047 ±5.99% 2124 · superjson 5,463.87 0.1525 1.0877 0.1830 0.1668 0.7494 0.8460 1.0877 ±4.88% 547 tests/benchmark.bench.ts > benchmark > complex data > decode - small 407ms name hz min max mean p75 p99 p995 p999 rme samples · codablejson 29,806.52 0.0304 0.2429 0.0335 0.0329 0.0361 0.0422 0.2369 ±1.30% 2981 · superjson 17,753.50 0.0500 0.3205 0.0563 0.0548 0.0672 0.2338 0.3092 ±1.52% 1776 tests/benchmark.bench.ts > benchmark > complex data > encode - small (no preserve refs) 406ms name hz min max mean p75 p99 p995 p999 rme samples · codablejson 25,394.95 0.0319 1.3072 0.0394 0.0352 0.0409 0.0458 1.2718 ±7.28% 2540 · superjson 3,638.95 0.1531 18.5522 0.2748 0.1754 1.0328 1.6148 18.5522 ±36.52% 364 tests/benchmark.bench.ts > benchmark > complex data > decode - small (no preserve refs) 406ms name hz min max mean p75 p99 p995 p999 rme samples · codablejson 29,951.03 0.0302 0.2175 0.0334 0.0329 0.0395 0.0415 0.1940 ±1.01% 2996 · superjson 18,056.05 0.0501 0.2413 0.0554 0.0542 0.0652 0.1729 0.1977 ±1.00% 1806 tests/benchmark.bench.ts > benchmark > complex data > encode - avg 415ms name hz min max mean p75 p99 p995 p999 rme samples · codablejson 1,460.57 0.5659 1.7502 0.6847 0.6249 1.7420 1.7502 1.7502 ±5.83% 148 · superjson 348.01 2.4765 3.3156 2.8735 3.1347 3.3156 3.3156 3.3156 ±3.30% 35 tests/benchmark.bench.ts > benchmark > complex data > decode - avg 410ms name hz min max mean p75 p99 p995 p999 rme samples · codablejson 1,329.21 0.6902 0.9735 0.7523 0.7467 0.9650 0.9735 0.9735 ±1.03% 134 · superjson 1,144.66 0.7891 1.0923 0.8736 0.8608 1.0761 1.0923 1.0923 ±1.62% 115 tests/benchmark.bench.ts > benchmark > complex data > encode - avg (no preserve refs) 414ms name hz min max mean p75 p99 p995 p999 rme samples · codablejson 1,708.09 0.4832 1.7160 0.5854 0.5267 1.6675 1.7160 1.7160 ±6.55% 171 · superjson 337.89 2.5201 3.4291 2.9595 3.3088 3.4291 3.4291 3.4291 ±4.19% 34 tests/benchmark.bench.ts > benchmark > complex data > decode - avg (no preserve refs) 407ms name hz min max mean p75 p99 p995 p999 rme samples · codablejson 1,205.86 0.4722 15.9679 0.8293 0.6821 1.9024 15.9679 15.9679 ±30.63% 121 · superjson 1,149.56 0.7804 1.0951 0.8699 0.8612 1.0793 1.0951 1.0951 ±1.52% 115 tests/benchmark.bench.ts > benchmark > complex data > encode - large 483ms name hz min max mean p75 p99 p995 p999 rme samples · codablejson 216.55 3.6990 6.1078 4.6180 5.5463 6.1078 6.1078 6.1078 ±8.94% 22 · superjson 54.0048 17.9200 19.0082 18.5169 18.8204 19.0082 19.0082 19.0082 ±2.18% 6 tests/benchmark.bench.ts > benchmark > complex data > decode - large 433ms name hz min max mean p75 p99 p995 p999 rme samples · codablejson 217.53 4.4535 4.8501 4.5971 4.6817 4.8501 4.8501 4.8501 ±1.17% 22 · superjson 183.11 5.1466 5.6428 5.4612 5.5689 5.6428 5.6428 5.6428 ±1.35% 19 tests/benchmark.bench.ts > benchmark > complex data > encode - large (no preserve refs) 468ms name hz min max mean p75 p99 p995 p999 rme samples · codablejson 284.14 2.9276 5.0573 3.5194 4.1419 5.0573 5.0573 5.0573 ±6.69% 29 · superjson 37.6992 17.9725 49.4501 26.5258 19.7721 49.4501 49.4501 49.4501 ±91.77% 4 tests/benchmark.bench.ts > benchmark > complex data > decode - large (no preserve refs) 429ms name hz min max mean p75 p99 p995 p999 rme samples · codablejson 340.87 2.7328 3.1689 2.9337 3.0258 3.1689 3.1689 3.1689 ±1.33% 35 · superjson 185.93 5.0819 5.5893 5.3784 5.4585 5.5893 5.5893 5.5893 ±1.27% 19 tests/benchmark.bench.ts > benchmark > complex data > encode - huge 2030ms name hz min max mean p75 p99 p995 p999 rme samples · codablejson 27.3526 35.5884 38.7765 36.5596 36.1306 38.7765 38.7765 38.7765 ±6.51% 4 · superjson 6.6980 143.59 163.82 149.30 145.96 163.82 163.82 163.82 ±10.38% 4 tests/benchmark.bench.ts > benchmark > complex data > decode - huge 955ms name hz min max mean p75 p99 p995 p999 rme samples · codablejson 28.6544 34.5987 35.2783 34.8987 34.8627 35.2783 35.2783 35.2783 ±1.28% 4 · superjson 21.8000 45.4027 46.1305 45.8716 46.0827 46.1305 46.1305 46.1305 ±1.15% 4 tests/benchmark.bench.ts > benchmark > complex data > encode - huge (no preserve refs) 1943ms name hz min max mean p75 p99 p995 p999 rme samples · codablejson 41.1302 23.5985 24.7790 24.3130 24.7155 24.7790 24.7790 24.7790 ±2.90% 5 · superjson 6.3963 141.53 186.59 156.34 154.01 186.59 186.59 186.59 ±21.28% 4 tests/benchmark.bench.ts > benchmark > complex data > decode - huge (no preserve refs) 871ms name hz min max mean p75 p99 p995 p999 rme samples · codablejson 42.5339 23.3634 23.6537 23.5107 23.6287 23.6537 23.6537 23.6537 ±0.72% 5 · superjson 17.9188 47.4662 76.0539 55.8073 50.0072 76.0539 76.0539 76.0539 ±38.62% 4 BENCH Summary codablejson - tests/benchmark.bench.ts > benchmark > plain json > encode - 6mb 3.68x faster than superjson codablejson - tests/benchmark.bench.ts > benchmark > plain json > decode - 6mb 1.29x faster than superjson codablejson - tests/benchmark.bench.ts > benchmark > plain json > encode - 6mb (no preserve refs) 6.85x faster than superjson codablejson - tests/benchmark.bench.ts > benchmark > plain json > decode - 6mb (no preserve refs) 1.28x faster than superjson codablejson - tests/benchmark.bench.ts > benchmark > complex data > encode - small 3.89x faster than superjson codablejson - tests/benchmark.bench.ts > benchmark > complex data > decode - small 1.68x faster than superjson codablejson - tests/benchmark.bench.ts > benchmark > complex data > encode - small (no preserve refs) 6.98x faster than superjson codablejson - tests/benchmark.bench.ts > benchmark > complex data > decode - small (no preserve refs) 1.66x faster than superjson codablejson - tests/benchmark.bench.ts > benchmark > complex data > encode - avg 4.20x faster than superjson codablejson - tests/benchmark.bench.ts > benchmark > complex data > decode - avg 1.16x faster than superjson codablejson - tests/benchmark.bench.ts > benchmark > complex data > encode - avg (no preserve refs) 5.06x faster than superjson codablejson - tests/benchmark.bench.ts > benchmark > complex data > decode - avg (no preserve refs) 1.05x faster than superjson codablejson - tests/benchmark.bench.ts > benchmark > complex data > encode - large 4.01x faster than superjson codablejson - tests/benchmark.bench.ts > benchmark > complex data > decode - large 1.19x faster than superjson codablejson - tests/benchmark.bench.ts > benchmark > complex data > encode - large (no preserve refs) 7.54x faster than superjson codablejson - tests/benchmark.bench.ts > benchmark > complex data > decode - large (no preserve refs) 1.83x faster than superjson codablejson - tests/benchmark.bench.ts > benchmark > complex data > encode - huge 4.08x faster than superjson codablejson - tests/benchmark.bench.ts > benchmark > complex data > decode - huge 1.31x faster than superjson codablejson - tests/benchmark.bench.ts > benchmark > complex data > encode - huge (no preserve refs) 6.43x faster than superjson codablejson - tests/benchmark.bench.ts > benchmark > complex data > decode - huge (no preserve refs) 2.37x faster than superjson

Summary

Encoding - CodableJSON is around ~3.5-4.2x faster than SuperJSON when encoding data, regardless of the size and complexity of the data. When not preserving references, performance improves significantly to ~5-7.5x faster.

Decoding - CodableJSON is consistently faster than SuperJSON across all test cases, with improvements ranging from 1.05x to 2.37x faster.

Dataset Details

Preserve refs means encoder analyzes the data to find out if the same object is seen multiple times and then, when decoding, will also re-use object references.

Copy refs means encoder will not preserve object references and decoded data will contain copies of the same object even if they were the same reference in the input.

Last updated on