HPJson HighPerformanceJson

How to Open Large JSON Files in a Browser Without Freezing

A browser usually freezes because it parses the entire file into memory and renders every node as a DOM element at once. Parse in a Web Worker, render only the nodes currently in view, and keep the file within a supported limit to keep the page responsive.

Why large files freeze the browser

Opening a 50MB JSON file involves more work than reading a text file. The browser must load the text, build an object tree with JSON.parse, and then turn each property into an interactive node. The text, the object tree, and a formatted copy may all exist in memory at the same time. When the node count reaches hundreds of thousands, layout and scrolling also become expensive. If all of this runs on the main thread, the page stops responding to clicks and scrolling.

A practical way to view large JSON in the browser

For files up to 100MB, you can use the view mode on hpjson.com without installing software or uploading the file:

  1. Open the site and switch to view mode.
  2. Choose a local JSON file and wait for parsing to finish.
  3. Collapse branches or search by path instead of expanding every node.

The site has been tested on macOS with 16GB of memory in Chrome: a 102.7MB dense object and a 100MB single string both passed. Actual performance depends on device memory and data shape, so the larger the file, the less you should expand at once. If a file exceeds 100MB, split it by business key on the server or with command-line tools first.

For a quick local check of whether a file parses and how many top-level entries it has, this minimal example does the work off the main thread:

const worker = new Worker(URL.createObjectURL(new Blob([`
self.onmessage = (event) => {
  try {
    const data = JSON.parse(event.data);
    const count = Array.isArray(data) ? data.length : Object.keys(data).length;
    self.postMessage({ ok: true, count });
  } catch (error) {
    self.postMessage({ ok: false, message: error.message });
  }
};
`], { type: "text/javascript" })));

document.querySelector("#json-file").addEventListener("change", async (event) => {
  const file = event.target.files[0];
  if (!file) return;
  if (file.size > 100 * 1024 * 1024) {
    console.log("File is over 100MB, split it first");
    return;
  }
  worker.postMessage(await file.text());
});

worker.onmessage = (event) => console.log(event.data);

The Worker receives the text, parses it, and posts back a small result, so the main thread stays free to respond.

How to avoid the problem in the future

FAQ

Can a 100MB file really open in a browser? The tool has a 100MB per-file limit. In tests on macOS with 16GB of memory and Chrome, a 102.7MB dense object and a 100MB single string passed. Speed depends on the device, and files over the limit should be split first.

Is my data uploaded? No. hpjson.com is a front-end tool that processes data locally and parses it in a Web Worker, so file contents do not leave the browser.

Why does the file look larger after formatting? Indentation, line breaks, and spaces add characters, and the formatted copy also takes memory. For a very large file, view it without formatting first.

Can a phone handle files this large? Phones usually have less memory. Keep files to a few tens of megabytes or split them before opening.

What if the file is over 100MB? Split it by record or page the export on the backend, then open each part separately.

To try it, open the JSON formatter and switch to view mode; for related questions, see the FAQ. The tool is free, currently has no ads, and is available in Chinese and English.