Opening a 2 GB CSV in the browser
A 2 GB CSV is about 32 million rows. Naive in-browser viewers die on it — but not where most people assume. This is what actually breaks, and what it takes to keep the file usable.
What breaks first
Not the parse. Papa.parse or a hand-rolled splitter will chew through 2 GB eventually. The failures come in this order:
String size. A single JS string cannot exceed roughly 512 MB on V8. Reading the file with FileReader.readAsText throws before parsing starts.
DOM nodes. One row per element means 32 million elements. Browsers slow to a crawl well before one million.
Scroll height. Browsers cap element height around 33.5 million pixels. At 24 px per row that is about 1.4 million rows — the scrollbar physically cannot represent the rest.
The five pieces that make it work
1. Byte-offset index. Read the file as an ArrayBuffer and store only the byte offset where each row starts, in a Uint32Array — 4 bytes per row, about 128 MB for 32 million rows. Row content is read on demand with subarray, never copied.
2. A worker. Building the index is a linear scan; it runs off the main thread so scrolling and typing never block. The worst frame gap we measured during indexing was 19 ms.
3. Windowed rendering. Only the rows in view plus a small overscan are mounted. A 40-row viewport renders 40 rows, whether the file has 4,000 or 32 million.
4. Scaled scrolling. Because the scrollbar tops out near 1.4 million rows, scroll position is mapped: a 33.5-million-pixel scrollbar stands in for 32 million rows, and the view jumps to the mapped index on scroll end.
5. Cached index. The byte-offset array is stored in IndexedDB keyed by file size and modification time, so reopening the same file skips the scan.
Measured, not estimated
Numbers from a 2 GB CSV of numeric and text columns on a desktop machine:
| Operation | Result |
|---|---|
| Open + index | 4.9 s |
| Peak memory | 263 MB |
| Rows | 31.9 M |
| Jump to row 30,000,000 | works, ~1 frame |
| Fuzzy search, 2,000 hits | 69 ms |
| 127.5 MB XLSX → CSV | 500,001 rows in ~4 s |
Memory stays in the low hundreds of megabytes because the file is never fully in memory as strings — only the index is, and it is 4 bytes per row.
XLSX is a different problem
An XLSX is a ZIP of XML. Unzipping a 100 MB workbook in memory explodes to several hundred megabytes. The workable path is streaming: walk the ZIP central directory, inflate entries with DecompressionStream('deflate-raw'), parse <row> elements as they arrive, and write the result to disk with the Origin Private File System before indexing it — the index then points at the OPFS file, not at the original XLSX.
What you give up
This is a viewer, not a spreadsheet. No formulas, no cell editing, no charts. Multi-sheet workbooks are read sheet by sheet, and XLSX is converted to CSV on the way in. If you need to compute on the data, export it and load it in pandas — the point here is finding the row you care about without waiting for Excel to open.