@xmldom/xmldom

A pure JavaScript, W3C-standard DOMParser and XMLSerializer for parsing and building XML/HTML documents

Library
npm
v0.9.12
474 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
89 /100 Excellent
Development Activity 96
Maintenance 96
Community 76
Maturity 60
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
73 /100 Good
Architecture 78
Code Quality 82
Innovation 62
Learning Curve 70

@xmldom/xmldom is a dependency-free JavaScript implementation of the DOM Level 2 Core API, providing DOMParser and XMLSerializer classes that work identically in Node.js and browsers. It exists to fill the gap left by document.implementation not being available server-side, giving Node code (and any environment lacking a native DOM) a spec-compliant way to parse XML/HTML strings into a traversable DOM tree and serialize a tree back to a string.

What You Get

  • A DOMParser class with parseFromString() that turns an XML or HTML string into a standards-compliant DOM Document
  • An XMLSerializer class that turns a DOM tree back into a string, mirroring the browser API
  • A hand-written SAX-style tokenizer (lib/sax.js) and grammar module underpinning the parser, with no native bindings or WASM to install
  • Configurable error/warning handling via onError callbacks so malformed input can be caught instead of silently producing a broken tree

Common Use Cases

  • Parsing XML config files, SOAP responses, RSS/Atom feeds, or SVG documents in a Node.js backend with no DOM available
  • Server-side rendering or testing code that expects browser DOM APIs (DOMParser/XMLSerializer) but runs outside a browser
  • Feeding parsed documents into XPath libraries (e.g. xpath) that expect a DOM Level 2 tree to query against
  • Manipulating and re-serializing HTML/XML documents in build tools, static site generators, or CLI utilities

Under The Hood

Architecture The library is organized around a small set of focused modules: sax.js implements a hand-rolled streaming tokenizer that walks the input string and emits parse events; dom-parser.js consumes those events to build up a DOM tree using the Document/Node/Element classes defined in the large dom.js (3,500+ lines implementing DOM Level 2 Core); entities.js handles the full HTML/XML named-entity decoding table; and errors.js/conventions.js centralize error typing and shared helpers. There is no external parsing dependency — the tokenizer, grammar, and DOM implementation are all original code. Tech Stack Pure JavaScript (CommonJS, lib/index.js as the entry point) with hand-authored TypeScript declarations (index.d.ts) shipped alongside rather than generated from source; zero runtime dependencies keep the install footprint small, and the dev toolchain uses Jest for testing, ESLint/Prettier for style, and auto-changelog for release notes. Code Quality The test suite is substantial — 64+ test files under test/ covering dom, dom-parser, entities, errors, grammar, HTML parsing, and dedicated conformance/parse suites, plus a jest.fuzz.config.js for fuzz testing malformed input, which is unusually thorough for a parser library and reflects real-world hardening against XML edge cases (external entities, malformed tags, encoding quirks). API Design The public API deliberately mirrors the browser’s native DOMParser/XMLSerializer interfaces, so code written against real browser DOM parsing can often switch to this package with a single import change and no rewrites; the tradeoff is that advanced configuration (custom error handling, MIME type selection) requires reaching for slightly less-discoverable constructor options rather than a fluent builder API.

Used by 14 apps in this directory

JavaScript
64%
AGPL 3.0

overleaf

Collaboration · Productivity

18,266

Open-source, real-time collaborative LaTeX editor with sandboxed compilation and full TeXLive support for self-hosted academic and research teams.

View details
84
Repo Health
80
Technical
59
Dependency
Built with
JavaScript 64%
TypeScript 30%
Updated 1 months ago
TypeScript
90%
MIT

Plasmic

CMS · Design Tools · Low Code Platforms

7,125

The open-source visual builder that lets teams design React apps and websites with drag-and-drop while integrating seamlessly with your codebase.

View details
81
Repo Health
78
Technical
64
Dependency
Built with
TypeScript 90%
Updated 6 days ago
TypeScript
97%
Other

Rocket.Chat

Team Chat

46,304

The secure, self-hosted team communications platform for organizations that cannot compromise on data sovereignty.

View details
96
Repo Health
79
Technical
63
Dependency
Built with
TypeScript 97%
Updated 5 days ago
TypeScript
91%
MIT

Super Productivity

Productivity · Project Management

23,103

A privacy-respecting, local-first task manager with built-in timeboxing, Pomodoro timer, and deep integrations for Jira, GitHub, GitLab, and CalDAV — no accounts, no data collection, ever.

View details
91
Repo Health
81
Technical
69
Dependency
Built with
TypeScript 91%
Updated 5 days ago
TypeScript
67%
Other

TaskView

Productivity · Project Management

1,367

Self-hosted project and task management platform for software teams, with Kanban boards, sprints, time tracking, GitHub/GitLab integrations, and an MCP server for AI assistants.

View details
78
Repo Health
77
Technical
68
Dependency
Built with
TypeScript 67%
Vue 21%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers