You double-click a JSON file and your editor freezes. Or the browser tab goes white and says the page is not responding. This happens a lot with big files, like database exports, logs and API dumps.
The good news: you almost never need to load the whole file at once. This guide shows simple ways to look inside a large JSON file and work with it. You can use a browser tool or the command line.
Quick answer: First check the file size. Then open it in a tree viewer that only shows the parts you open. For very large files, split them into JSON Lines (one record per line). Or read them with a streaming tool such as jq or Python’s ijson.
Why do large JSON files slow everything down?
A few things happen at once when you open a big JSON file:
- The whole file goes into memory. A normal JSON parser (the code that reads JSON) must read everything before it gives you anything back.
- The data takes more space than the file. Every object, key and string becomes a separate item in memory. This can need several times the size of the file.
- Editors do extra work. They add colours, fold sections, check for errors and wrap lines. They do this for the whole text. A minified file is one huge line, and it is often the slowest of all.
- Browsers draw every item. Some pages turn a large file into thousands of screen items at once. Those pages freeze.
So the fix is the same everywhere: load less, or show less.
Step 1: Check how big the file is
Before you open the file, look at its size. On Mac or Linux, run ls -lh big.json. On Windows, right-click the file and choose Properties.
To see the first part of the file without opening it, run head -c 1000 big.json.
If the file is a few megabytes, most tools can handle it. For a closer look, paste it into the JSON Size Analyzer. It shows the raw size, the minified size and the gzipped (compressed) size.
It also shows the largest branches, the keys that repeat most and how deep the nesting goes. So you can see what takes up the space. It runs in your browser, so your data is not uploaded.
Is the file hundreds of megabytes or more? Then skip to the streaming section below. Any tool that loads the whole file will have trouble, in a browser or not.
Step 2: Open it in a tree viewer
A tree viewer shows JSON like a list of folders. You can open and close each one. The best tree viewers only build the parts you open. So the size of the file matters much less.
The JSON Viewer works this way. It only draws the children of a node when you open it. Big arrays load 300 items at a time.
Each node shows how many keys or items it holds. So you can see where most of the data is before you open it.
Is your file a list of records? Then a table is often easier to read than a tree. The JSON Table Viewer shows an array of objects as rows and columns.
You can sort by any column and filter the rows. Rows are shown page by page, so long arrays stay fast.
Step 3: Make the file smaller
Minify it
Minifying removes the spaces and line breaks that only help people read JSON. The data stays exactly the same. If the file has a lot of indentation, this can save a good part of the size.
Learn more in how to minify JSON. But remember: minifying does not remove any records. A parser still has the same amount of work to do.
Remove what you don’t need
The Size Analyzer often shows that one branch is most of the file. For example, images stored inside the JSON, or debug data. If you don’t need it, remove it at the source, before you export the file.
What is JSON Lines (NDJSON)?
JSON Lines is a simple way to store many records. It is also called NDJSON (newline-delimited JSON). You don’t use one big array. You put one full JSON object on each line:
{"id": 1, "event": "login", "user": "ada"}
{"id": 2, "event": "upload", "user": "sam"}
{"id": 3, "event": "logout", "user": "ada"}Each line is valid JSON by itself. This helps you in some big ways:
- A program can read one line, use it and forget it. So it uses little memory.
- You can split the file with normal tools, like
split -l 100000 big.jsonl. - You can add new records to the end without writing the whole file again.
But the file as a whole is not valid JSON. There is no outer array, and there are no commas between lines. So your tools must know they are reading JSON Lines.
Reading it in Python takes only a few lines:
import json
with open("big.jsonl") as f:
for line in f:
record = json.loads(line)
print(record["event"])How to stream a large JSON file
A streaming parser reads the file a little at a time. It gives you each item as soon as it finds it. It never holds the whole file in memory. This is how you work with files that are bigger than your computer’s memory.
On the command line with jq
jq is a free command-line tool for reading and filtering JSON. Here are a few useful commands:
jq 'length' big.json # how many items in the top-level array
jq '.[0]' big.json # show the first item
jq '.[] | select(.status == "failed") | .id' big.json
jq -c '.[]' big.json > big.jsonl # turn an array into JSON LinesThese commands still load the whole file first. For files that are too big for that, jq has a streaming mode. This command turns a huge top-level array into JSON Lines without loading it all:
jq -cn --stream 'fromstream(1|truncate_stream(inputs))' big.json > big.jsonlIn Python with ijson
ijson is a Python library that streams JSON. Install it with pip install ijson. This code reads the items of a top-level array one by one:
import ijson
with open("big.json", "rb") as f:
for item in ijson.items(f, "item"):
print(item["id"])The "item" part means “each item of the top-level array”. Sometimes the array is under a key, like {"data": [...]}. Then use "data.item" instead.
A simple plan for any large JSON file
- Check the size. Look at the start of the file to see its shape.
- For small and medium files, use a tree or table viewer that only draws what you open.
- Find what takes up the space. Remove it or minify it if you can.
- For huge files, change them to JSON Lines or use a streaming tool.
- If you create the data yourself, write JSON Lines from the start.
Common questions
Is there a maximum size for a JSON file?
The JSON standard has no size limit. The real limits come from your computer’s memory and your tools. Some parsers also set their own limit.
What is the difference between JSON Lines and NDJSON?
In practice, they are the same idea with two names. Each line holds one JSON value. Most tools that read one can read the other.
Why is my JSON file one long line?
It was minified. This is normal for API responses and exports. A formatter or tree viewer will show it with indentation again. The data does not change.
Can I open a large JSON file in Excel?
Only if it is an array of flat records. Even then, Excel has a limit on the number of rows. See how to convert JSON to Excel for the details.