Skip to content

Getting Started

StAX-XML is a high-performance, pull-based XML parser for JavaScript/TypeScript that works across all JavaScript runtimes.

Install StAX-XML using your preferred package manager:

Terminal window
# npm
npm install stax-xml
# yarn
yarn add stax-xml
# pnpm
pnpm add stax-xml
# bun
bun add stax-xml
# deno
deno add npm:stax-xml

StAX-XML uses only Web Standard APIs, making it compatible with:

  • Node.js (v18+)
  • Bun (any version)
  • Deno (any version)
  • Web Browsers (modern browsers)
  • Edge Runtime (Vercel, Cloudflare Workers, etc.)

StAX-XML provides two main parsing approaches:

For memory-efficient processing of large XML files using streams:

import { StaxXmlParser } from 'stax-xml';
const parser = new StaxXmlParser(readableStream);
for await (const event of parser) {
// Process XML events
}

For high-performance parsing of smaller, in-memory XML strings:

import { StaxXmlParserSync } from 'stax-xml';
const parser = new StaxXmlParserSync(xmlString);
for (const event of parser) {
// Process XML events
}