Convert XML to JSON
Convert XML to formatted JSON. Elements become keys and attributes are kept with an @_ prefix. Parsed in your browser with fast-xml-parser, no upload.
Why convert XML to JSON?
JSON is easier to work with in JavaScript and most modern APIs. Turn an XML feed, a sitemap, a SOAP response or a config export into JSON and it becomes simpler to read and change in code.
How to convert XML to JSON
Drop an .xml file above and press Convert. fast-xml-parser reads it in your browser. Elements become object keys and repeated sibling elements become arrays. Attributes are kept with an @_ prefix, so no information is lost and attributes never clash with child elements. The JSON is indented with two spaces.
Compatibility
The parser handles nested elements, attributes, namespaces and text content. Numeric text such as 42 is read as a number. An element that appears once becomes an object while the same element repeated becomes an array, so code reading the JSON should handle both shapes. If the XML is broken, you get an error instead of partial output.
A quick example
The XML <order id="7"><item>Pen</item><item>Ink</item></order> becomes an object with an order key holding @_id set to 7 and item set to an array of Pen and Ink. A single item element would give a plain string instead of an array, which is worth handling in any code that reads the JSON.
Before you start
Input: XML. Output: JSON. The settings appear before anything runs, so you can check them first. Your original file is never changed.
A valid file can still hold the wrong data. Before you import the result, check the row count, field names, text encoding, dates, IDs and a few unusual rows.
Keep the original until you have opened and checked the result. The work happens in this browser tab, so the size you can handle depends on your device's memory, your browser and the file itself.
Steps to convert XML to JSON
- Drop an .xml file into the box above.
- Press Convert to parse it in your browser.
- Download the JSON.
Last updated · How we build and check tools · Report an error