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.
🌐
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
🌐
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
🌐
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.
🌐
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
🌐
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 ...
🌐
GitHub
github.com › commenthol › xml-vs-js
GitHub - commenthol/xml-vs-js: Convert XML/ HTML to Javascript and vice versa · GitHub
const {toJs} = require('xml-vs-js') const xml = ` <?xml version="1.0" encoding=utf-8 ?> <feed xmlns="http://www.w3.org/2005/Atom"> <title>Example Feed</title> <entry> <title>Entry</title> <link href="http://example.org/2003/12/13/atom03" /> <link rel="alternate" type="text/html" href="http://example.org/2003/12/13/atom03.html"/> </entry> <entry> <title>Update</title> </entry> </feed> ` toJs(xml, (err, obj) => { console.log(obj) /* { _elems: ['_PROCESSING', 'feed'], _PROCESSING: { _text: '?xml version="1.0" encoding=utf-8 ?' }, feed: { _attrs: { xmlns: 'http://www.w3.org/2005/Atom' }, _elems: [
Author   commenthol
🌐
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 10737 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 ...
🌐
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.
🌐
David Walsh
davidwalsh.name › convert-xml-json
Convert XML to JSON with JavaScript
November 25, 2015 - Hi I also thank you for this article Using your function presented in this page I created and used the javascript object posted on this page: http://coursesweb.net/javascript/convert-xml-json-javascript_s2 It returns json object or string directly from file or string with xml.