
Company News
Free Business Plan Upgrades for Open Source Maintainers
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.
fast-xml-builder
Advanced tools
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.
npm install fast-xml-builder
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.
{
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,
}
Check Options reference for more detail and examples.
arrayNodeName to wrap each element in a tag name.'@_'.preserveOrder: true.<![CDATA[...]]>.<!-- ... -->.format: true for human-readable, indented output.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.' ' (two spaces). Only applies when format: true.100.preserveOrder: true, pass the same option to XMLBuilder to reconstruct the original XML correctly.true (default), special characters in text and attribute values are replaced with XML entities (&, <, 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.Expression instances from path-expression-matcher. The old *.tagName wildcard syntax is still accepted and automatically converted to the equivalent ..tagName deep-wildcard syntax.true (default), attributes with the value true are rendered without the value (e.g. <tag attr> instead of <tag attr="true">).true, tags with no text value are rendered as self-closing (<tag/>).true (default), unpaired tags are rendered without a closing slash (<br>). When false, they are rendered as <br/>.'#text'.<br> in HTML).xml2js is a popular library for converting XML to JavaScript objects and vice versa. It offers more comprehensive XML parsing capabilities compared to fast-xml-builder, which focuses primarily on building XML from JSON.
xmlbuilder is another library for building XML documents in Node.js. It provides a more feature-rich API for constructing XML, including support for namespaces and complex document structures, whereas fast-xml-builder is optimized for speed and simplicity.
js2xmlparser is a library that converts JavaScript objects to XML. It offers similar functionality to fast-xml-builder but includes additional options for customizing the output, such as different attribute and value handling.
FAQs
Build XML from JSON without C/C++ based libraries
The npm package fast-xml-builder receives a total of 41,235,069 weekly downloads. As such, fast-xml-builder popularity was classified as popular.
We found that fast-xml-builder demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.