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

fast-xml-builder

v1.2.0

Published

Build XML from JSON without C/C++ based libraries

Readme

fast-xml-builder

Build XML from JSON

XML Builder was part of fast-xml-parser for years. But considering that any bug in the parser may false-alarm users who are only using the builder, we have decided to split it into a separate package.

Installation

npm install fast-xml-builder

Usage

import XMLBuilder from 'fast-xml-builder';

const builder = new XMLBuilder();
const xml = builder.build({ name: 'value' });

fast-xml-builder fully supports the response generated by fast-xml-parser. You can use options like preserveOrder, ignoreAttributes, attributeNamePrefix, textNodeName, cdataPropName, commentPropName, format, indentBy, suppressEmptyNode, suppressUnpairedNode, stopNodes, oneListGroup, maxNestedTags, and many more.

Default Options

{
  attributeNamePrefix: '@_',
  attributesGroupName: false,
  textNodeName: '#text',
  ignoreAttributes: true,
  cdataPropName: false,
  commentPropName: false,
  format: false,
  indentBy: '  ',
  suppressEmptyNode: false,
  suppressUnpairedNode: true,
  suppressBooleanAttributes: true,
  preserveOrder: false,
  processEntities: true,
  unpairedTags: [],
  stopNodes: [],
  oneListGroup: false,
  maxNestedTags: 100,
  jPath: true,
  tagValueProcessor: (key, val) => val,
  attributeValueProcessor: (attrName, val) => val,
}

Options Reference

Check Options reference for more detail and examples.

  • arrayNodeName: When building XML from an array, set arrayNodeName to wrap each element in a tag name.
  • attributeNamePrefix: Prefix used to identify attribute properties in the JS object. Default: '@_'.
  • attributesGroupName: Group name for attributes in the JS object. When set, all attributes are expected to be nested under this key. Not supported with preserveOrder: true.
  • attributeValueProcessor: Customize how attribute values are serialized. Receives the attribute name and value.
  • cdataPropName: Property name that identifies CDATA content. Values under this key are wrapped in <![CDATA[...]]>.
  • commentPropName: Property name that identifies comment content. Values under this key are rendered as <!-- ... -->.
  • format: By default, output is a single-line XML string. Set format: true for human-readable, indented output.
  • ignoreAttributes: By default (true), attributes are skipped. Set to false to include them. Also supports selective ignoring via an array of strings, array of regular expressions, or a callback function.
  • indentBy: String used for each level of indentation. Default: ' ' (two spaces). Only applies when format: true.
  • maxNestedTags: Limits the maximum depth of nested tags. An error is thrown if this depth is exceeded. Default: 100.
  • oneListGroup: Groups all repeated child tags under a single parent tag.
  • preserveOrder: When a JS object was produced by XMLParser with preserveOrder: true, pass the same option to XMLBuilder to reconstruct the original XML correctly.
  • processEntities: When true (default), special characters in text and attribute values are replaced with XML entities (&amp;, &lt;, etc.). Set to false for a performance boost when you know your content has no entities. Note: quotes in attribute values are always escaped regardless of this setting.
  • stopNodes: Tags listed here are treated as raw content containers — their text content is written as-is without entity encoding. Accepts an array of tag name strings or Expression instances from path-expression-matcher. The old *.tagName wildcard syntax is still accepted and automatically converted to the equivalent ..tagName deep-wildcard syntax.
  • suppressBooleanAttributes: When true (default), attributes with the value true are rendered without the value (e.g. <tag attr> instead of <tag attr="true">).
  • suppressEmptyNode: When true, tags with no text value are rendered as self-closing (<tag/>).
  • suppressUnpairedNode: When true (default), unpaired tags are rendered without a closing slash (<br>). When false, they are rendered as <br/>.
  • tagValueProcessor: Customize how tag text values are serialized. Receives the tag name and value.
  • textNodeName: Property name representing the text content of a tag in the JS object. Default: '#text'.
  • unpairedTags: List of tag names that have no matching closing tag (e.g. <br> in HTML).