
Product
PHP and Composer Support Is Now in Beta
Socket’s PHP and Composer support is now in Beta for all customers, with PHP reachability analysis generally available.
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 29,774,288 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.

Product
Socket’s PHP and Composer support is now in Beta for all customers, with PHP reachability analysis generally available.

Product
Socket is bringing experimental protection to Firefox, scanning 97,000+ extensions in Mozilla's official directory for malware and risky updates.

Research
/Security News
Three compromised Rust crates pulled in a malicious dependency that downloaded and executed cross-platform malware during Cargo builds.