npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

stax-xml

v1.1.2

Published

High-performance, pull-based XML parser for JavaScript/TypeScript with declarative converter API

Readme

StAX-XML

A StAX-style, pull-based XML parser and writer for JavaScript and TypeScript, designed for bounded memory and strong performance. The package is intentionally pure JavaScript: the parser core, stream readers, event readers, converter, and writer all run without binary parser modules or backend selection.

Goals

  • Keep memory usage low for large XML documents.
  • Parse XML that is larger than JavaScript's single-string comfort zone by consuming streams and byte batches.
  • Provide a StAX-style pull API so applications do not need to keep deep SAX state machines in user code.
  • Keep async work at I/O ingress boundaries. Once a byte batch has arrived, tokenization and event draining stay synchronous.
  • Stay portable across Node, Bun, Deno, browsers, and edge runtimes.

Why Pure JavaScript?

We explored native and Wasm tokenizer acceleration first. Native code can scan XML bytes very quickly, but the public stax-xml contract is JavaScript consumption: callers read names, text, attributes, events, and objects as JavaScript values.

That boundary adds decode, allocation, wrapper, and ownership costs. It also adds native heap or Wasm linear memory to RSS. Because this package is optimized for low memory, very large XML, and pull-based JavaScript consumption, the native experiment was moved out of this package.

Install

npm install stax-xml

The package is ESM-only.

import { EventReaderSync, XmlEventType } from 'stax-xml';

const reader = new EventReaderSync('<root><item id="1">hello</item></root>');

for (const event of reader) {
  if (event.type === XmlEventType.START_ELEMENT) {
    console.log(event.name, event.attributes);
  }
}

Public Surfaces

  • stax-xml: StreamReaderSync, EventReaderSync, StreamReader, EventReader, and the writers.
  • stax-xml/converter: recommended schema-driven XML-to-object parsing and XML writing.
  • StreamReaderSync / StreamReader: allocation-sensitive current-token readers.
  • EventReaderSync / EventReader: stable event-object readers built over the same token core.
  • Writer, WriterSync, WriterSyncSink: XML output APIs, including a sync sink path for large output.

Both synchronous readers accept string, Uint8Array, or Iterable<Uint8Array>. Strings are scanned directly as JavaScript strings; they are never re-encoded to bytes. Both asynchronous readers accept ReadableStream<Uint8Array> or AsyncIterable<Uint8Array> and decode bytes incrementally with a fatal TextDecoder; encoding defaults to UTF-8. For known object output, start with the converter.

These are the only public package entry points. The package has no default export, runtime adapters, tree/DOM helpers, or backend-selection API.

Benchmarks

Benchmark scripts live under packages/benchmark. The maintained runtime comparison is:

pnpm --dir packages/benchmark bench:runtime-matrix

It compares the same JavaScript reader workload across Node, Bun, and Deno when those runtimes are installed.

Release Guides

  • Migrating from v0.x maps older application code to the pure JavaScript 1.0 reader and writer surfaces.
  • Web Server Integration shows request streaming patterns for Express, Fastify, Hono, Next.js, Bun, Deno, and edge runtimes.
  • Release Readiness records the packaging, benchmark, docs, and merge checklist used before publishing.

License

MIT