@xmldom/xmldom
A pure JavaScript, W3C-standard DOMParser and XMLSerializer for parsing and building XML/HTML documents
Repository Health
Technical Analysis
@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
DOMParserclass withparseFromString()that turns an XML or HTML string into a standards-compliant DOMDocument - An
XMLSerializerclass 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
onErrorcallbacks 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
overleaf
Collaboration · Productivity
Open-source, real-time collaborative LaTeX editor with sandboxed compilation and full TeXLive support for self-hosted academic and research teams.
Plasmic
CMS · Design Tools · Low Code Platforms
The open-source visual builder that lets teams design React apps and websites with drag-and-drop while integrating seamlessly with your codebase.
Rocket.Chat
Team Chat
The secure, self-hosted team communications platform for organizations that cannot compromise on data sovereignty.
Super Productivity
Productivity · Project Management
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.
TaskView
Productivity · Project Management
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.