JSON Toolkit

Performance and Security

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 articles

Articles in this category

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.

Intermediate~13 min readUpdated 2026-10-31

Security Risk Checklist for JSON Processing

JSON.parse itself is safe; the danger is what happens after it: deep merging, assignment by path, inlining into HTML, unlimited depth and size.

Intermediate~12 min readUpdated 2026-10-30

Large JSON File Won't Open? Pick the Right Tool by Size

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.

Advanced~6 min readUpdated 2026-11-07

jq on Large JSON Files: Why -s Blows Up Memory and How to Stream Instead

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.

Advanced~6 min readUpdated 2026-11-12

Parsing Large JSON in Python, Benchmark: stdlib, orjson, and msgspec

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.

Advanced~6 min readUpdated 2026-11-15

Reading Big JSON in Node.js: stream-json Streaming and Backpressure in Practice

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.

Intermediate~5 min readUpdated 2026-11-17