Pure JavaScript XML to JSON Converter – xml2json.js

Category: Javascript | April 2, 2016
Views Total:5,683 views
Official Page:Go to website
Last Update:April 2, 2016


Pure JavaScript XML to JSON Converter – xml2json.js


xml2json.js is a pure JavaScript library that converts XML strings into more human-readable JSON data.

How to use it:

Just download and load the xml2josn library into your document and done.

<script src="xml2json.js"></script>

Get the XML in a string.

var xmlInput = document.getElementById('xmlInput').value;

Call the xml2json function

var jsonOutput = xml2json(xmlInput);

Beautify the JSON if needed.

var beautifiedJson = JSON.stringify(jsonOutput, undefined, 4);

Show the json output in a textarea

document.getElementById('jsonOutput').innerHTML = beautifiedJson;

You Might Be Interested In:

Leave a Reply