To open a large JSON file without crashing your browser, don't load the whole file at once. Stream it with a tool like jq --stream or Python's ijson, pull out a few records or just the structure, and open those small pieces in a browser viewer. The browser only freezes when you ask it to parse and draw everything in one go.
Why a big JSON file crashes the browser tab
A browser tab crashes on big JSON because a normal parser has to hold the entire file as one string and then build every object from it. JSON.parse takes one complete string, and JavaScript strings have a hard ceiling: the Node.js Buffer documentation notes that the maximum string length is exposed as buffer.constants.MAX_STRING_LENGTH. A file that can't fit in one string can't go through JSON.parse in one call.
Below the ceiling, memory is the problem. The parsed objects take far more room than the text did. A tree viewer then adds page elements for keys and values, and the tab stops responding while it works.
Which tool to open a large JSON file with
The right way to open a large JSON file depends on what you need from it. Most people need one of four things:
| What you need | Use | Why it works |
|---|---|---|
| See the shape of the data | jq --stream |
Reads the file in pieces, never all at once |
| Look at a few sample records | jq or ijson, then a viewer | The browser sees kilobytes, not the full file |
| Process every record in code | ijson (Python) or a streaming parser | One record in memory at a time |
| Peek at the first bytes in a web app | Blob.slice() |
Reads a byte range without touching the rest |
My take: if a file is big enough to make you ask, start on the command line. Open a browser only once you have a sample. You'll have your answer before a frozen tab comes back.
Stream it with jq instead of loading it
jq handles large files through its --stream mode, which emits small path-and-value pairs instead of one giant parsed document. The jq manual says streaming lets programs "start processing large JSON texts immediately rather than after the parse completes", and that a single 1GB JSON text can be processed much more quickly this way.
Each streamed event looks like [<path>, <leaf-value>], plus a [<path>] event when an array or object ends. Those are awkward to read. Two built-ins turn them back into normal JSON: truncate_stream strips the outer path, and fromstream rebuilds whole values.
Say orders.json is one huge array of order objects. This prints the first record, compact, on one line:
jq -cn --stream 'fromstream(1|truncate_stream(inputs))' orders.json | head -n 1
-nwithinputsmakes jq read the events one by one.1|truncate_stream(...)drops the array index from each path.fromstream(...)rebuilds each array element as a complete object.-cprints each object on a single line, soheadcan stop after the first.
Avoid --slurp here. The manual describes it as reading the entire input into a large array, which is exactly the memory spike you are trying to dodge. If jq output is new to you, pretty-printing JSON with jq covers the everyday flags.
Turn the array into one record per line, then split
Converting a big JSON array to one record per line makes the file easy to split and browse. Drop the head from the command above and redirect the output:
jq -cn --stream 'fromstream(1|truncate_stream(inputs))' orders.json > orders.ndjson
Now each line is a full JSON object. That layout is called NDJSON or JSON Lines, explained in what the NDJSON format is. Ordinary line tools work on it: head for a sample, split -l for chunks, grep to find one customer.
Firefox reads these files too. According to the Firefox JSON viewer documentation, JSON Lines files show up with one collapsible entry per non-blank line, and objects start collapsed with a search box to filter them.
Read it record by record in Python with ijson
ijson is the Python option when you need to process every record, not just look at a few. The ijson project page calls it "an iterative JSON parser with standard Python iterator interfaces", and ijson.items yields Python objects found under a prefix. The prefix item means "each element of the top-level array".
import ijson
with open("orders.json", "rb") as f:
for order in ijson.items(f, "item"):
if order["status"] == "failed":
print(order["id"])
Only one order sits in memory at a time. ijson reads the file in buffered chunks (buf_size defaults to 65536 bytes, or 64KB), so a long array doesn't change how much memory the loop uses.
Peek at the first bytes in the browser
A web page can look at part of a large file without reading all of it by slicing the file. A File from an <input type="file"> is a Blob, and MDN's Blob.slice() page explains that it returns a new Blob with just a byte range, leaving the original untouched.
const head = await file.slice(0, 65536).text();
console.log(head); // the opening bytes only
That's enough to see how the file starts: is it an array, an object with a data key, or NDJSON? For real processing, Blob.stream() hands you the contents as a ReadableStream of byte chunks, which you can feed to a streaming parser.
A byte slice usually cuts a value in half, so JSON.parse on it fails with an error like the one in Unexpected end of JSON input. That's expected: a slice is for looking, not parsing.
Viewing the sample once you have it
A few extracted records are small enough for any normal viewer. Paste one into the JSON viewer to fold and expand it as a tree. OnlineViewer Dev processes pasted input with JavaScript in the page, the tool code makes no network requests with it, and the input isn't saved. That matters when the sample holds real customer data.
The limitation: browser viewers, this one included, parse the whole pasted text before showing anything. Use them for the sample. Never paste the multi-gigabyte original. For general ways to open normal-sized files, see what opens a .json file.
If the tab is already frozen
A frozen tab can be closed on its own without restarting the browser. In Chrome, the Google Chrome Help page on speeding up Chrome gives the steps:
- Select More, then More tools, then Task Manager.
- Select Memory to sort tasks by memory use.
- Select the stuck tab.
- Select End Process.
Google warns that any unsaved work in that task will be lost, so save other work in that tab first if you can.
FAQ
Why does my browser freeze when I open a big JSON file?
A normal JSON parser needs the whole file as one string in memory, then builds every object and array from it. A viewer that draws a tree adds page elements on top. On a big file that work blocks the tab until it finishes or runs out of memory.
Can jq open a JSON file that is too big for memory?
Yes, with the --stream option. The jq manual says streaming lets a program start processing large JSON texts immediately rather than after the whole parse completes.
How do I read a large JSON file in Python without loading it all?
Use the ijson library. ijson.items(f, 'item') yields the elements of a top-level array one at a time, so memory stays flat no matter how long the array is.
How do I close a frozen Chrome tab?
Open More, More tools, Task Manager, sort by Memory, select the stuck tab and choose End Process. Anything unsaved in that tab is lost.
Is it better to split a large JSON file?
Usually, yes. Converting a big top-level array to one record per line lets you split it with ordinary line tools and open any piece on its own.