I think this is the best one: Converting between XML and JSON

Be sure to read the accompanying article on the xml.com O'Reilly site, which goes into details of the problems with these conversions, which I think you will find enlightening. The fact that O'Reilly is hosting the article should indicate that Stefan's solution has merit.

Answer from Josh Stodola on Stack Overflow
🌐
GitHub
github.com › nashwaan › xml-js
GitHub - nashwaan/xml-js: Converter utility between XML text and Javascript object / JSON text.
TIP: In non-compact mode, you probably want to set {textKey: 'value', cdataKey: 'value', commentKey: 'value'} to make it more consistent and easier for your client code to go through the contents of text, cdata, and comment. For XML → JS object / JSON, following custom callback functions can be supplied: var convert = require('xml-js'); var xml = '<foo:Name>Ali</Name> <bar:Age>30</bar:Age>'; var options = {compact: true, elementNameFn: function(val) {return val.replace('foo:','').toUpperCase();}}; var result = convert.xml2json(xml, options); console.log(result); // {"NAME":{"_text":"Ali"},"BAR:AGE":{"_text":"30"}}
Starred by 1.3K users
Forked by 179 users
Languages   JavaScript 97.3% | CSS 1.4% | JavaScript 97.3% | CSS 1.4%
🌐
Loco
localise.biz › free › converter › xml-to-js
Convert XML language packs to JavaScript
Free tool converts XML language packs including TMX translation files to JavaScript and JSON.
🌐
npm
npmjs.com › package › xml-js
xml-js - npm
February 13, 2019 - Convert XML text to Javascript object / JSON text (and vice versa).
      » npm install xml-js
    
Published   Feb 13, 2019
Version   1.6.11
Author   Yousuf Almarzooqi
🌐
FreeFormatter
freeformatter.com › xml-to-json-converter.html
Free Online XML to JSON Converter - FreeFormatter.com
This free online tool lets you convert an XML file into a JSON file with your choice of indentation
🌐
ConvertSimple
convertsimple.com › convert-xml-to-javascript-object
Convert XML to JavaScript Object Online - ConvertSimple.com
October 17, 2020 - Convert XML to a JavaScript object or array with this simple online XML to JavaScript converter tool.
🌐
JSON Formatter
jsonformatter.org › xml-to-javascriptproptypes
Best XML to JavaScript PropTypes Converter to convert JavaScript PropTypes Code.
Secure XML to JavaScript PropTypes Converter. It easy to use and generated JavaScript PropTypes Code based on XML also Support XML File and URL.
Find elsewhere
🌐
Teleport
goteleport.com › resources › tools › xml-to-json-converter
XML to JSON Converter | Instant XML to JSON Conversion | Teleport
Convert XML data to JSON instantly with our free online tool. Simplify your data conversions with fast, accurate processing.
🌐
CSS Script
cssscript.com › home › javascript › convert xml to javascript object – from-xml
Convert XML To JavaScript Object – from-xml | CSS Script
February 20, 2023 - CSS Script Best Free JavaScript & CSS/CSS3 Libraries For Modern Web Design ... A tiny XML To JS Object converter library that works with both browser and node.js.
🌐
Code Beautify
codebeautify.org › xmltojson
XML to JSON Converter Online to convert XML to JSON String, URL and File
If you're looking for an easy way to convert XML to JSON, you've come to the right place. Our XML to JSON converter is free and easy to use, simply paste your XML code into the input and hit the "XML to JSON" button.
🌐
SourceForge
sourceforge.net › projects › xml2js.mirror
xml2js download | SourceForge.net
August 21, 2025 - Download xml2js for free. XML to JavaScript object converter. xml2js is a Node.js module that converts XML into JavaScript objects (and vice versa). It simplifies XML parsing by using pure JavaScript and supports both synchronous and asynchronous ...
🌐
Toolexe
toolexe.com › xml › xml-to-javascript
XML to JavaScript Converter - Convert XML to JS Objects Online - Toolexe
Free online XML to JavaScript converter. Transform XML data to JavaScript objects, arrays, and code instantly. Support for nested elements and attributes.
🌐
npm
npmjs.com › package › xml-js-converter
xml-js-converter - npm
July 12, 2015 - Define your own rules for how to convert attributes and content. Latest version: 1.0.0, last published: 11 years ago. Start using xml-js-converter in your project by running `npm i xml-js-converter`. There are no other ...
      » npm install xml-js-converter
    
Published   Jul 12, 2015
Version   1.0.0
Author   Dave Brotherstone
🌐
npm
npmjs.com › package › xml2js
xml2js - npm
Simple XML to JavaScript object converter.. Latest version: 0.6.2, last published: 3 years ago. Start using xml2js in your project by running `npm i xml2js`. There are 10751 other projects in the npm registry using xml2js.
      » npm install xml2js
    
Published   Jul 26, 2023
Version   0.6.2
Author   Marek Kubica
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-convert-xml-to-json-in-javascript
How to Convert XML to JSON in JavaScript? | GeeksforGeeks
October 22, 2024 - It traverse the parsed XML document's nodes to extract element names and their corresponding text content, storing them in a JSON object for conversion and formatting. ... Example: Parses the given XML string to a JavaScript object using xmldom ...
🌐
GitHub
github.com › abdolence › x2js
GitHub - abdolence/x2js: x2js - XML to JSON and back for JavaScript · GitHub
x2js - XML to JSON and back for JavaScript. Contribute to abdolence/x2js development by creating an account on GitHub.
Starred by 1K users
Forked by 479 users
Languages   JavaScript 55.6% | HTML 44.4%
🌐
Attacomsian
attacomsian.com › blog › nodejs-convert-xml-to-json
How to convert XML to JSON in Node.js
October 1, 2022 - A step-by-step guide to learn how to convert an XML file or a string to a JSON object by using Node.js.
🌐
Online XML Tools
onlinexmltools.com › convert-xml-to-json
Convert XML to JSON - Online XML Tools
Simple, free and easy to use online tool that converts XML to JSON. No ads, popups or nonsense, just an XML to JSON converter. Load XML, get JSON.
🌐
Utilities and Tools
utilities-online.info › xmltojson
XML to JSON & JSON to XML converter online
Every single JSON property value will be converted to #item types. A specific default root element is created and the offending characters will be XML escaped. The given array entries are converted to individual XML elements. This online converter is a completely free and easy-to-use tool to convert XML to JSON format and vice versa.