Convert XML to JSON online instantly. Paste any XML document and get clean, structured JSON: attributes are preserved, nested elements become nested objects, and repeated tags become arrays. Everything runs 100% client-side in your browser, so your data never leaves your device.
100% client sideInstant resultNo data sent
Input/ XML
645 chars25 lines
Output/ JSON
Invalid XML
DOMParser is not defined
0 chars0 lines
Frequently asked questions
4 answers
XML attributes have no direct JSON equivalent, so the converter maps them to prefixed keys on the element's object (commonly written as "@name" or a similar marker). An element like <book id="1">Title</book> becomes an object that keeps both the id attribute and the text content, so no information is lost even though JSON has no attribute concept of its own.
When the same tag appears multiple times under one parent, the converter groups them into a JSON array. A list like <item>a</item><item>b</item><item>c</item> becomes "item": ["a", "b", "c"]. This is the natural JSON shape for lists and is exactly what most APIs and JavaScript code expect when iterating over repeated records.
The XML declaration (the <?xml version="1.0"?> line) describes the XML document itself: its version and character encoding. JSON has no equivalent concept and does not need one, since JSON is always UTF-8 by specification. The converter reads the declaration to parse the document correctly and then omits it from the JSON output, which is the correct behavior.
Yes. Namespaced element names like <soap:Envelope> or <xs:element> are kept as-is in the JSON keys, prefix included, so the structure of SOAP responses, RSS feeds, and XSD-flavored documents remains intact. If you prefer cleaner keys, you can post-process the JSON to strip prefixes, but preserving them avoids collisions between elements that share a local name.
Legacy SOAP services, RSS feeds, sitemaps, configuration files, and enterprise integrations still speak XML, while modern applications and REST APIs expect JSON. This XML to JSON converter translates between the two instantly: paste an XML document and get JSON that mirrors the original structure, with attributes preserved, nesting kept intact, and repeated elements grouped into arrays. The parser flags malformed XML with a clear error rather than guessing, so a missing closing tag is caught immediately. Because the converter is free and runs entirely in your browser, it is safe for API responses, invoices, and any XML payload containing sensitive data.