<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Yana Postnova</title>
    <description>The latest articles on DEV Community by Yana Postnova (@yana_postnova_3499025b3ea).</description>
    <link>https://dev.to/yana_postnova_3499025b3ea</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3825215%2Faf91fd69-926b-4491-b893-017e3a85c04c.png</url>
      <title>DEV Community: Yana Postnova</title>
      <link>https://dev.to/yana_postnova_3499025b3ea</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yana_postnova_3499025b3ea"/>
    <language>en</language>
    <item>
      <title>I built a Chrome extension that stream-parses 2GB XML files using only 20MB of RAM. Here's the architecture.</title>
      <dc:creator>Yana Postnova</dc:creator>
      <pubDate>Sun, 15 Mar 2026 11:11:55 +0000</pubDate>
      <link>https://dev.to/yana_postnova_3499025b3ea/i-built-a-chrome-extension-that-stream-parses-2gb-xml-files-using-only-20mb-of-ram-heres-the-4nk5</link>
      <guid>https://dev.to/yana_postnova_3499025b3ea/i-built-a-chrome-extension-that-stream-parses-2gb-xml-files-using-only-20mb-of-ram-heres-the-4nk5</guid>
      <description>&lt;p&gt;&lt;strong&gt;The problem&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The solution&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I built &lt;a href="https://chromewebstore.google.com/detail/xml-stream-parser/lippinogapmkocmbfdpkdlnbolimkloa" rel="noopener noreferrer"&gt;XML Stream Parser&lt;/a&gt; — a Chrome extension that handles XML files up to 2GB without freezing your browser.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How it works (the interesting part)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The core idea is embarrassingly simple: don't build a DOM tree.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;File.slice(offset, offset + 16MB)&lt;/code&gt; reads a chunk&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;TextDecoder({ stream: true })&lt;/code&gt; decodes UTF-8 correctly across chunk boundaries (this is the part everyone gets wrong — a multibyte character can land exactly on the boundary)&lt;/li&gt;
&lt;li&gt;A custom SAX parser processes the chunk, firing &lt;code&gt;onOpenTag&lt;/code&gt;, &lt;code&gt;onCloseTag&lt;/code&gt;, &lt;code&gt;onText&lt;/code&gt; events&lt;/li&gt;
&lt;li&gt;All of this runs in a &lt;strong&gt;Web Worker&lt;/strong&gt; so the main thread stays free&lt;/li&gt;
&lt;li&gt;Worker sends progress updates via &lt;code&gt;postMessage&lt;/code&gt;, main thread renders a progress bar&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Memory usage is ~20MB regardless of file size. A 2GB file uses the same RAM as a 2KB file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What you can do with it:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Stats&lt;/strong&gt;: total elements, unique tags, attributes, max depth — computed in a single pass&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Search&lt;/strong&gt;: filter by tag name, attribute name, attribute value, or text content. Results stream in real-time during parsing&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Element explorer&lt;/strong&gt;: all tags listed by nesting depth. Click any tag to see its actual XML code with syntax highlighting. Navigate through up to 50 samples with ◀ ▶&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;XML anatomy hint&lt;/strong&gt;: the extension picks a representative element from your file and shows an interactive breakdown — what's a tag, what's an attribute, what's a value. Useful for non-dev users who receive XML exports&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The SAX parser gotcha&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I wrote a minimal SAX parser from scratch (~200 lines) instead of using sax-js because I needed it to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Handle &lt;code&gt;parser.write(chunk)&lt;/code&gt; for incremental feeding&lt;/li&gt;
&lt;li&gt;Not allocate a tree&lt;/li&gt;
&lt;li&gt;Correctly handle CDATA, comments, PIs, and entity decoding across chunk boundaries&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The trickiest part was self-closing tags like &lt;code&gt;&amp;lt;Foo bar="1"/&amp;gt;&lt;/code&gt; — the &lt;code&gt;/&lt;/code&gt; can end up in the next chunk if it lands on the boundary. The solution: the parser buffers incomplete tags until the closing &lt;code&gt;&amp;gt;&lt;/code&gt; arrives.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Numbers from a real test:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;File&lt;/th&gt;
&lt;th&gt;Size&lt;/th&gt;
&lt;th&gt;Elements&lt;/th&gt;
&lt;th&gt;Parse time&lt;/th&gt;
&lt;th&gt;RAM&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Hotel reservations&lt;/td&gt;
&lt;td&gt;1.8 GB&lt;/td&gt;
&lt;td&gt;2.4M&lt;/td&gt;
&lt;td&gt;3.4s&lt;/td&gt;
&lt;td&gt;~20MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Product catalog&lt;/td&gt;
&lt;td&gt;890 MB&lt;/td&gt;
&lt;td&gt;1.1M&lt;/td&gt;
&lt;td&gt;1.7s&lt;/td&gt;
&lt;td&gt;~18MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API log dump&lt;/td&gt;
&lt;td&gt;450 MB&lt;/td&gt;
&lt;td&gt;6.2M&lt;/td&gt;
&lt;td&gt;2.1s&lt;/td&gt;
&lt;td&gt;~16MB&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Stack&lt;/strong&gt;: Vanilla JS, Web Workers, zero dependencies. The entire extension is 45KB.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://chromewebstore.google.com/detail/xml-stream-parser/lippinogapmkocmbfdpkdlnbolimkloa" rel="noopener noreferrer"&gt;Chrome Web Store link&lt;/a&gt; | Free, no tracking, all processing is local.&lt;/p&gt;

&lt;p&gt;Would love feedback — especially if you have edge-case XML files that break things.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>javascript</category>
      <category>performance</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
