https://devtools.solutions/tools/xml/xml-to-json.html

XML to JSON

Convert an XML document to a JSON representation. Attributes, text, and child elements are all preserved.


    

Frequently Asked Questions

Can I convert XML to JSON?

Yes. Paste your XML and click XML to JSON to generate a JSON representation that preserves attributes and nested elements.

How are XML attributes handled?

Element attributes are represented as prefixed keys (e.g. @id) in the output JSON object.

Is XML conversion done server-side?

No. XML conversion is processed entirely in your browser using DOMParser.

Example input/output

Input: <user id="1"><name>Ada</name></user>

Output: {"user":{"@id":"1","name":"Ada"}}

How it works

This tool parses the XML with DOMParser and recursively converts the DOM tree to a JavaScript object. Element attributes become prefixed keys (e.g. @id), child elements become nested keys, and text content is preserved as string values. Processing runs in your browser.

Common use cases

Related tools