How can I handle an 850 MB JSON response in JavaScript?

September 23, 2026 3 answers
Asked by 6stringLute
I'm making an API request with Axios, and the response contains nearly 850 MB of JSON. The request appears to succeed, but response.data is an empty string. The same approach worked with about 300 MB, so I'm guessing I'm hitting a size or memory limit. I understand that streaming would be preferable, but for now I need to receive and parse the entire JSON document. Is there a way to make this work reliably?

Answers

verb__collector
The practical fix is to change the API contract: paginate the records, return a downloadable file, or provide a streamable format such as NDJSON. A single 850 MB JSON response is fragile and difficult to restart if the connection fails. If you control the server, split the data into smaller chunks and process each chunk independently.
Reply to this answer
L2.syntax
If the complete document is unavoidable, use a streaming HTTP response and an incremental JSON parser instead of letting Axios buffer the whole body. For a normal JSON array, the parser needs to emit individual items as they arrive; for NDJSON, process one line at a time. Also make sure the Node process has sufficient heap space, but increasing the heap alone will not bypass V8โ€™s maximum string length or eliminate the memory overhead of parsing.
Reply to this answer
heap64m
You may be hitting Node.js/V8โ€™s maximum string size or running out of memory while Axios buffers the response and JSON.parse creates another large in-memory representation. A document this large can require considerably more than 850 MB because the raw response, JavaScript string, parsed object, and temporary allocations may coexist. Check the actual error and enable detailed logging rather than treating an empty value as a successful response.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions