How are XML attributes handled in the JSON output?
XML element attributes (e.g., `<item id="123">`) are converted to JSON keys with an underscore prefix, like `"_id": "123"`. This distinguishes them from child element names in the output object.
XML to JSON Converter transforms XML documents into clean JSON structures directly in your browser. Modern applications built with Node.js, React, or REST APIs expect JSON, but many legacy systems — SAP, SOAP web services, RSS feeds, Android configs — still output XML. This tool bridges that gap without writing a parser or installing a library.
XML and JSON represent data differently: XML uses elements with attributes and text content, while JSON uses objects and arrays. This converter maps XML element names to JSON keys, element text content to string values, attributes to underscore-prefixed keys (like "_id"), and repeated sibling elements with the same name to JSON arrays. The conversion runs in the browser using the built-in DOMParser API.
XML element attributes (e.g., `<item id="123">`) are converted to JSON keys with an underscore prefix, like `"_id": "123"`. This distinguishes them from child element names in the output object.
Yes. When multiple sibling elements share the same tag name (e.g., multiple `<user>` elements under `<users>`), the converter groups them into a JSON array. A single element stays as an object.
Yes. Conversion runs entirely in your browser using the browser's DOMParser API. No data is sent to any server, making this safe for HIPAA-sensitive data, financial records, and proprietary API payloads.
Self-closing or empty XML tags resolve to null or an empty string in the JSON output. The key is preserved so the data structure remains intact, even if the value is empty.
Namespace prefixes (e.g., `soap:envelope`, `xs:string`) are preserved as part of the key name in the JSON output. The namespace URI is not resolved, but the prefixed key names remain readable and accurate.
Tool workspace
Free XML to JSON converter online — instantly transform rigid XML documents into flexible, modern JSON structures for API integration. Clean UI, local processing.
Output
Input
<person id="1"> <name>John</name> <city>NYC</city> </person>
Output
{"person": {"_id":"1","name":"John","city":"NYC"}}