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

xml-disassembler

v1.11.5

Published

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

Readme

xml-disassembler

NPM License Downloads/week Maintainability Code Coverage Known Vulnerabilities

Split large XML files into smaller, version-control–friendly pieces—then reassemble them when needed. Output as XML, INI, JSON, JSON5, TOML, or YAML.

Useful for cleaner diffs, easier collaboration, and workflows like Salesforce metadata.

Rust implementation: For a native, high-performance alternative, see xml-disassembler-rust.


Table of contents


Quick start

import {
  DisassembleXMLFileHandler,
  ReassembleXMLFileHandler,
} from "xml-disassembler";

// Disassemble: one XML → many small files
const disassemble = new DisassembleXMLFileHandler();
await disassemble.disassemble({
  filePath: "path/to/YourFile.permissionset-meta.xml",
  uniqueIdElements:
    "application,apexClass,name,flow,object,recordType,tab,field",
  format: "json",
  strategy: "unique-id",
});

// Reassemble: many small files → one XML
const reassemble = new ReassembleXMLFileHandler();
await reassemble.reassemble({
  filePath: "path/to/YourFile",
  fileExtension: "permissionset-meta.xml",
});

Features

  • Disassemble – Break XML into smaller components (by unique ID or by tag).
  • Reassemble – Rebuild the original XML from disassembled output.
  • Multiple formats – Output (and reassemble from) XML, INI, JSON, JSON5, TOML, or YAML.
  • Strategiesunique-id (one file per nested element) or grouped-by-tag (one file per tag).
  • Ignore rules – Exclude paths via a .xmldisassemblerignore file (same style as .gitignore).
  • Logging – Configurable logging via log4js (writes to disassemble.log by default).
  • Salesforce-friendly – Fits metadata and similar XML-heavy workflows.

Reassembly preserves element content and structure; element order may differ (especially with TOML).


Install

npm install xml-disassembler

Disassembling

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 to disassemble. | | uniqueIdElements | Comma-separated element names used to derive filenames for nested elements. | | prePurge | Remove existing disassembly output before running (default: false). | | postPurge | Remove the source XML after disassembly (default: false). | | ignorePath | Path to the ignore file (default: .xmldisassemblerignore). | | format | Output format: xml, ini, json, json5, toml, yaml. | | strategy | unique-id or grouped-by-tag. |


Disassembly strategies

unique-id (default)

Each nested element is written to its own file, named by a unique identifier (or a SHA-256 hash if no UID is available). Leaf content stays in a file named after the original XML.

Best for fine-grained diffs and version control.

Example layouts

| Format | UID-based layout | Hash-based layout | | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 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

All nested elements with the same tag go into one file per tag. Leaf content stays in the base file named after the original XML.

Best for fewer files and quick inspection.

Example layouts

| Format | Layout | | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | XML | XML tag | | YAML | YAML tag | | JSON | JSON tag | | JSON5 | JSON5 tag | | TOML | TOML tag | | INI | INI tag |


Reassembling

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 that contains the disassembled files (e.g. HR_Admin/). | | fileExtension | Suffix for the rebuilt XML file (e.g. permissionset-meta.xml). Default: .xml. | | postPurge | Remove disassembled files after a successful reassembly (default: false). |


Ignore file

Exclude files or directories from disassembly using an ignore file (default: .xmldisassemblerignore). Syntax matches node-ignore (similar to .gitignore).

Example:

# Skip these paths
**/secret.xml
**/generated/

Logging

Logging uses log4js. By default, logs go to disassemble.log at error level.

import { setLogLevel } from "xml-disassembler";

setLogLevel("debug"); // Verbose logging

XML parser

Parsing is done with fast-xml-parser, with support for:

  • CDATA"![CDATA["
  • Comments"!---"
  • Attributes"@__**"

Use case

For a Salesforce CLI integration example, see sf-decomposer.


Contributing

See CONTRIBUTING.md for code style, PR process, and coverage expectations.


License

This project is based on a template by Allan Oricil; the original template code is under the ISC license. The xml-disassembler code is under the MIT license.