
I built a Chrome extension that stream-parses 2GB XML files using only 20MB of RAM. Here's the architecture.
The problem I work with hotel reservation systems that dump SOAP/OTA XML responses — sometimes 1-2 GB per file. Every XML viewer I tried either crashed, froze the tab, or ran out of memory. Notepad++ tops out around 200MB. Browser-based XML viewers load everything into a DOM tree that eats 3-10x the file size in RAM. A 500MB file? That's 4GB of RAM just to render it. The solution I built XML Stream Parser — a Chrome extension that handles XML files up to 2GB without freezing your browser. How it works (the interesting part) The core idea is embarrassingly simple: don't build a DOM tree. File.slice(offset, offset + 16MB) reads a chunk TextDecoder({ stream: true }) decodes UTF-8 correctly across chunk boundaries (this is the part everyone gets wrong — a multibyte character can land exactly on the boundary) A custom SAX parser processes the chunk, firing onOpenTag , onCloseTag , onText events All of this runs in a Web Worker so the main thread stays free Worker sends progress updates via
Continue reading on Dev.to JavaScript
Opens in a new tab
