node-xml2js

XML-to-JavaScript-object parser and builder for Node.js

Library
npm
v0.6.2
4,967stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
48/100Fair
Development Activity12
Maintenance0
Community80
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
66/100Good
Architecture70
Code Quality65
Innovation55
Learning Curve72

xml2js is a long-standing Node.js library that converts XML documents into plain JavaScript objects and can build XML back from JavaScript data structures. It wraps the SAX-based sax parser under a simpler, callback/promise-based API, exposing configuration options for common XML parsing headaches: attribute handling, namespace resolution, explicit-array normalization, whitespace trimming, and custom tag/attribute name processors.

Because raw XML-to-object conversion is ambiguous (should a repeated child element become an array? should attributes be nested under a special key or merged into the object?), xml2js’s large set of parser options exists specifically to let consumers pick the shape that matches how they intend to use the resulting object, rather than imposing one opinionated mapping. This flexibility, combined with its long track record and near-ubiquitous adoption in the Node ecosystem, is why it remains the default choice for parsing SOAP responses, RSS/Atom feeds, config files, and other legacy XML formats in JavaScript backends.

What You Get

  • A Parser class (and shorthand parseString/parseStringPromise functions) that converts an XML string into a plain JavaScript object
  • A Builder class that serializes a JavaScript object back into an XML string, using xmlbuilder internally
  • Configurable attribute handling (explicitArray, mergeAttrs, attrkey/charkey) to control the exact shape of the resulting object
  • XML namespace support, including stripping or preserving namespace prefixes during parsing
  • Custom tagNameProcessors/attrNameProcessors/valueProcessors hooks for transforming names and values during parsing

Common Use Cases

  • Parsing SOAP API responses into JavaScript objects for further processing
  • Reading legacy XML configuration files (e.g. web.config, Maven pom.xml-style files) in Node.js tooling
  • Converting RSS/Atom XML feeds into JSON-like structures for feed readers or aggregators
  • Round-tripping XML in migration or ETL scripts that need to modify a document and re-serialize it
  • Interfacing with older enterprise systems and APIs that only expose XML endpoints

Under The Hood

Architecture The library is a thin, well-organized wrapper around two lower-level packages: sax for the actual XML tokenizing/parsing and xmlbuilder for serialization. lib/parser.js (the largest file, ~395 lines) implements the Parser class, which drives a sax stream and, on each SAX event (open tag, text, close tag), incrementally builds up the target JavaScript object according to the active options; lib/builder.js mirrors this in reverse, walking a JS object and emitting an xmlbuilder document. lib/defaults.js centralizes the option presets for the two supported parsing “modes” (0.1 legacy defaults vs 0.2 current defaults), and lib/processors.js implements the built-in name/value processor functions (e.g. stripPrefix, parseNumbers) that users can opt into.

Tech Stack Source is written in CoffeeScript (src/) and compiled to the published CommonJS JavaScript (lib/) via a Cakefile build script; the only runtime dependencies are sax (XML tokenizing) and xmlbuilder (XML serialization) — both mature, minimal libraries.

Code Quality Tests are written in CoffeeScript (test/*.test.coffee) covering the parser, builder, BOM-handling, and processor functions, run via nyc/zap with Coveralls coverage reporting wired into CI. Since core logic is compiled from CoffeeScript rather than hand-written JS, contributors need CoffeeScript familiarity to modify lib/ directly (or must edit src/ and rebuild), which is an unusual but consistent pattern for a project this size and age.

API Design The primary entry points — parseString(xml, callback), parseStringPromise(xml), and new Builder().buildObject(obj) — are simple and immediately usable with zero configuration, while the large options object (explicitArray, mergeAttrs, explicitRoot, attrkey, etc.) is layered on top for cases needing precise control over the JS-object shape. This two-tier design (simple defaults, deep configurability) is why it has remained a stable dependency for over a decade despite XML parsing inherently requiring many edge-case decisions.

Used by 19 apps in this directory

TypeScript
99%
Other

Activepieces

Automation · AI Assistants

23,887

Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.

View details
92
Repo Health
85
Technical
65
Dependency
Built with
TypeScript99%
Updated today
TypeScript
94%
MIT

Actual

Invoicing Finance

28,224

Local-first personal finance with envelope budgeting, end-to-end encryption, and multi-device sync — no subscription required.

View details
93
Repo Health
85
Technical
77
Dependency
Built with
TypeScript94%
Updated yesterday
TypeScript
69%
Other

Budibase

Low Code Platforms · No Code Platforms

28,220

Build AI agents, automations, and internal apps on a single open-source platform with full self-hosting control.

View details
92
Repo Health
81
Technical
63
Dependency
Built with
TypeScript69%
Svelte26%
Updated today
Rust
67%
MIT

Bun

Developer Tools

95,452

An all-in-one JavaScript and TypeScript toolkit — one Rust-and-JavaScriptCore binary that replaces Node.js, npm, a bundler, and a test runner with faster equivalents.

View details
92
Repo Health
91
Technical
66
Dependency
Built with
Rust67%
C++19%
Updated today
C++
51%
Other

Cocos Engine

Developer Tools · Game Development · Design Tools

9,761

Open-source, cross-platform 2D/3D game engine with Vulkan, Metal, and WebGL support for web, mobile, and instant gaming platforms

View details
68
Repo Health
79
Technical
71
Dependency
Built with
C++51%
TypeScript35%
Updated 1 months ago
TypeScript
93%
AGPL 3.0

CourseLit

Ecommerce · Blogging

1,255

Open-source, self-hosted LMS for selling online courses, digital downloads, and building communities on your own branded website.

View details
78
Repo Health
74
Technical
72
Dependency
Built with
TypeScript93%
Updated 4 weeks ago
TypeScript
75%
Apache 2.0

Fern

Developer Tools

3,761

Fern turns a single OpenAPI, AsyncAPI, or Protobuf definition into type-safe SDKs for nine languages and a hosted API documentation site, all from one CLI and one source of truth.

View details
90
Repo Health
86
Technical
67
Dependency
Built with
TypeScript75%
Updated today
TypeScript
72%
AGPL 3.0

Firecrawl

AI Development · Developer Tools

169,311

Turn any website into clean, LLM-ready data with a single API call — no proxy headaches, no scraping complexity.

View details
89
Repo Health
83
Technical
66
Dependency
Built with
TypeScript72%
Python14%
Updated today
TypeScript
54%
Other

Focalboard

Productivity · Project Management · Collaboration

26,409

Self-hosted, open source project management with Kanban, table, gallery, and calendar views — a privacy-first alternative to Trello, Notion, and Asana.

View details
58
Repo Health
82
Technical
67
Dependency
Built with
TypeScript54%
Go40%
Updated 3 months 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

Search