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 🙏

© 2025 – Pkg Stats / Ryan Hefner

xml-disassembler

v1.11.3

Published

Disassemble XML files into smaller, more manageable files and reassemble the XML when needed.

Downloads

345

Readme

xml-disassembler

NPM License Downloads/week Maintainability Code Coverage Known Vulnerabilities

Disassemble large XML files into smaller, modular files in formats like XML, INI, JSON, JSON5, TOML, or YAML—then reassemble them as needed.

Designed for improved version control, cleaner diffs, and easier team collaboration when dealing with complex XML structures.


Features

  • Disassemble XML Files – Break down XML into smaller components.
  • Reassemble XML – Rebuild the original XML from disassembled parts.
  • Multiple Output Formats – Choose XML, INI, JSON, JSON5, TOML, or YAML.
  • Two Disassembly Strategies – Choose between unique-id (default) or grouped-by-tag.
  • Ignore Rules – Exclude files from processing using an ignore file.
  • Logging – Log errors and debug information using log4js.
  • Salesforce Integration – Supports use cases like Salesforce metadata processing.

Note: Reassembly guarantees element-level fidelity, but element order may vary—especially when using TOML.


Background

Managing large XML files—especially those generated by tools—can be painful. xml-disassembler solves this by splitting them into digestible pieces, optimized for Git diffs and team workflows.

No need for complex diffing tools—just structured directories with format-flexible files.


Install

Install the package using NPM:

npm install xml-disassembler

Disassembling Files

import { DisassembleXMLFileHandler } from "xml-disassembler";

const handler = new DisassembleXMLFileHandler();
await handler.disassemble({
  filePath: "test/baselines/general",
  uniqueIdElements:
    "application,apexClass,name,externalDataSource,flow,object,apexPage,recordType,tab,field",
  prePurge: true,
  postPurge: true,
  ignorePath: ".xmldisassemblerignore",
  format: "json",
  strategy: "unique-id",
});

| Option | Description | | ------------------ | -------------------------------------------------------------------------------------- | | filePath | Path to the XML file or directory | | uniqueIdElements | Comma-separated list of UID elements for naming nested files | | prePurge | Delete previous disassembly output before running (true or false, default false) | | postPurge | Delete the original XML after disassembly (true or false, default false) | | ignorePath | Path to the ignore file (default .xmldisassemblerignore) | | format | Output format: xml, ini, json, json5, toml, yaml | | strategy | Disassembly strategy: unique-id or grouped-by-tag |


Disassembly Strategies

unique-id (default)

This is the strategy all previous versions of the xml-disassembler follow.

Each nested element is written to a separate file based on its unique identifier—or a SHA-256 hash fallback. Leaf elements remain grouped in a file named after the original XML.

Best for detailed diffs and granular version control.

Example Outputs

| Format | UID Example | Hash Example | | --------- | ------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------- | | XML | XML UID | XML Hash | | YAML | YAML UID | YAML Hash | | JSON | JSON UID | JSON Hash | | JSON5 | JSON5 UID | JSON5 Hash | | TOML | TOML UID | TOML Hash | | INI | INI UID | INI Hash |

grouped-by-tag

Groups all nested elements by tag into a single file. Leaf elements still go into a base file named after the original XML.

Best for fewer files and easier manual inspection.

Example Outputs

| Format | Grouped by Tag Example | | --------- | ----------------------------------------------------------------------------------------------------------------------------- | | XML | XML tag | | YAML | YAML tag | | JSON | JSON tag | | JSON5 | JSON5 tag | | TOML | TOML tag | | INI | INI tag |


Reassembling Files

import { ReassembleXMLFileHandler } from "xml-disassembler";

const handler = new ReassembleXMLFileHandler();
await handler.reassemble({
  filePath: "test/baselines/general/HR_Admin",
  fileExtension: "permissionset-meta.xml",
  postPurge: true,
});

| Option | Description | | --------------- | ------------------------------------------------------------------------------------------ | | filePath | Directory containing disassembled files to reassemble | | fileExtension | Extension for the output XML file (default: .xml) | | postPurge | Delete disassembled files after successful reassembly (true or false, default false) |


Use Case

See sf-decomposer for a Salesforce CLI use case.


Ignore File

Create an ignore file, similar to a .gitignore, to exclude XMLs from disassembly.

uses node-ignore


XML Parser

Uses fast-xml-parser with support for:

  • Character Data (CDATA): "![CDATA["
  • Comments: "!---"
  • Attributes: "@__**"

Logging

Logging uses log4js. Logs are written to disassemble.log.

import { setLogLevel } from "xml-disassembler";

setLogLevel("debug"); // Enables verbose logging

Contributing

Contributions are welcome! See Contributing.


Template & License

This project is based on a template by Allan Oricil and licensed under the ISC license. The original code remains under the ISC license.

All contributions specific to the xml-disassembler is licensed under the MIT license.