Parsing, Rendering, and Streaming Large JSON
Parsing is often not the bottleneck; rendering and copying are. Optimize along the four layers "parse → traverse → render → transport" so your effort is not wasted.
A JSON file of tens of megabytes can freeze the main thread, and carefully crafted JSON can punch through a service; this category covers both throughput and defenses.
9 articlesParsing is often not the bottleneck; rendering and copying are. Optimize along the four layers "parse → traverse → render → transport" so your effort is not wasted.
JSON.parse itself is safe; the danger is what happens after it: deep merging, assignment by path, inlining into HTML, unlimited depth and size.
Minifying cuts 30-50% off raw JSON, but gzip erases most of that gain. Measured numbers across real shapes, plus the four cases where minifying makes things worse.
A 10MB JSON file can become 30-50MB in the V8 heap. Learn what strings, objects and numbers really cost, how to baseline with process.memoryUsage, and when streaming helps.
Stutter starts when DOM nodes are created, not when you scroll. Covers collapse-first rendering, virtual lists, search highlighting and Worker boundaries, with metrics.
A multi-megabyte JSON export often freezes text editors and online viewers, yet parsing it takes only a few hundred milliseconds. We benchmarked a 45 MB, 500,000-record sample to measure time and memory at each stage, show why line count and node count are the real cost, and provide a size-based tool decision table covering online viewing, command-line extraction, streaming, and desktop apps.
A few hundred MB of JSON logs killed by jq -s can be aggregated in a few MB of RAM with reduce inputs. Measured on a 220MB, 2-million-line sample: slurp peaked at 2.08GB while the streaming reducer stayed at 3.5MB. This guide explains where the memory goes, the right way to process JSONL line by line, --stream path events, and three real pitfalls including silent empty output from -n --stream.
The same NDJSON star-counting script takes 754 ms with the standard json library but only 146 ms with msgspec declarative decoding, and multi-core parallelism pushes it another order of magnitude. This article benchmarks stdlib, orjson, and msgspec step by step on a 61.4 MB, 300,000-line sample, and explains exactly where each speedup comes from and when it runs out.
Parsing a 186MB JSON array with readFileSync plus JSON.parse peaks at 612MB of resident memory; switching to stream-json's streamArray keeps it flat at 104MB. This guide walks through measured results for four reading strategies, explains why for await provides backpressure for free, how the data event loses it, and how to size highWaterMark and drain on the write side.