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

@eksml/xml

v0.2.0

Published

Fast, lightweight XML/HTML parser, serializer, and streaming toolkit

Readme

Eksml

CI coverage npm license

A fast, lightweight XML/HTML parser, serializer, and streaming toolkit for JavaScript and TypeScript. Import only what you need, tree parsing, SAX streaming, object conversion, or serialization, each as a standalone export.

Built on the same core parsing architecture as tXml by Tobias Nickel, Eksml improves the performance and extends it with additional features.

Try the interactive demo

Installation

pnpm add @eksml/xml
# or: npm install @eksml/xml / yarn add @eksml/xml

Eksml is ESM-only and requires Node.js 18+ (or any modern browser, Deno, or Bun). There are no CommonJS exports.

Parsing

parse() turns an XML string into an array of plain-object nodes:

import { parse } from '@eksml/xml/parser';

const dom = parse('<feed><item id="1">Hello</item></feed>');
// [
//   {
//     tagName: 'feed',
//     attributes: null,
//     children: [
//       { tagName: 'item', attributes: { id: '1' }, children: ['Hello'] },
//     ],
//   },
// ]

Every element is a TNode, { tagName, attributes, children }, and text is a plain string. That's the whole tree model, it's JSON-serializable and safe to clone.

Prefer working with simple objects instead of a tree? Convert directly:

import { lossy } from '@eksml/xml/lossy';

lossy('<user><name>Alice</name><age>30</age></user>');
// => { user: { name: 'Alice', age: '30' } }

See parsing for all options (HTML mode, strict mode, entity decoding, targeted extraction) and converters for the lossy and lossless object formats.

Writing

write() serializes a tree (or a lossy/lossless object, auto-detected) back to a string:

import { write } from '@eksml/xml/writer';

write(dom);
// => '<feed><item id="1">Hello</item></feed>'

write(dom, { pretty: true });
// => '<feed>\n  <item id="1">Hello</item>\n</feed>'

write({ user: { name: 'Alice' } });
// => '<user><name>Alice</name></user>'

See writing for pretty-printing, entity encoding, HTML output, and validation options.

Streaming

For documents too large to hold in memory, or data arriving over the network, XmlParseStream is a standard web TransformStream that emits parsed subtrees as they complete:

import { XmlParseStream } from '@eksml/xml/stream';

const response = await fetch('/feed.xml');
const nodes = response.body
  .pipeThrough(new TextDecoderStream())
  .pipeThrough(new XmlParseStream({ select: 'item' }));

for await (const item of nodes) {
  console.log(item.tagName); // each <item> as soon as it closes
}

The select option emits matching elements individually instead of waiting for the whole document. Works in browsers, Node.js 18+, Deno, and Bun; Node streams bridge in with Readable.toWeb().

If you want raw events instead of trees (or maximum throughput), there's also an EventEmitter-style SAX parser:

import { createSaxParser } from '@eksml/xml/sax';

const parser = createSaxParser();
parser.on('openTag', (tagName, attributes) => console.log(tagName));
parser.write('<feed><item id="1">');
parser.write('Hello</item></feed>');
parser.close();

See web streams and SAX parser for options, output formats, and Node stream interop.

Documentation

Benchmarks

Eksml is consistently the fastest JavaScript library at DOM parsing, SAX streaming, and raw tokenization, and leads serialization with validate: false. Full per-fixture results: BENCHMARKS.md.

There is also an interactive benchmark that runs in your browser. It is a separate suite from BENCHMARKS.md: it only includes libraries that run on the web, and uses its own fixtures (or XML you paste in), so its numbers are not directly comparable.

Acknowledgments

Eksml's DOM parser is built on the work of Tobias Nickel and his tXml library. The core parsing architecture, a single-pass, position-tracking string scanner that builds the tree as it goes, is what makes both libraries so fast. Thank you, Tobias, for the elegant approach that made all of this possible.

License

MIT