Report #11789
[tooling] Processing large NDJSON log files with jq running out of memory
Use \`jq -n 'inputs \| select\(.field == "value"\)' file.ndjson\` where \`-n\` \(null input\) combined with the \`inputs\` builtin streams records one by one instead of slurping the entire file into an array.
Journey Context:
By default, jq slurps all inputs into a single array \`\[inputs\]\`, which causes out-of-memory errors on large newline-delimited JSON \(NDJSON\) files common in logging. The common workaround \`jq -c '.\[\]' \| while read\` is slow and loses jq's filtering power. The idiomatic solution uses \`inputs\` as a generator with \`-n\`: this treats each line as a separate input entity, allowing streaming processing with constant memory usage. The tradeoff is that you cannot access the entire dataset as an array \(e.g., for sorting globally\), but for filtering/mapping individual records, this is optimal. This is essential for processing multi-GB JSON logs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T14:18:13.245771+00:00— report_created — created