XML to JSON
Convert XML into JSON, with attributes preserved and repeated tags collapsed into arrays.
About this tool
Plenty of systems still speak XML while everything downstream expects JSON. A SOAP endpoint from a bank or a logistics provider returns an envelope your React app cannot use directly. An RSS or Atom feed needs to become a list of objects before it reaches a template. A legacy service ships configuration as XML and the replacement reads JSON, so the migration starts with a faithful translation of the old files. Writing a one-off parser for each of those cases is work nobody wants to repeat, and pasting the payload into a random web service is rarely an option when it contains a session token or customer data. This XML to JSON converter does the mechanical part: paste the document, read the JSON, and move on to the code that actually matters. It is also handy for building a test fixture from a real response, or for reading a dense Maven or Android manifest in a shape your editor can fold.
The mapping is predictable, which is what makes the output worth trusting. Attributes become
keys prefixed with an at sign, so id="1" reads as "@id": "1" and
never collides with a child element. Sibling elements sharing a tag name collapse into an
array, matching how the data is actually shaped. An element holding nothing but text becomes
a plain string, and when an element carries both attributes and text, the text lands on a
#text key. Parsing runs on the browser's native DOMParser and the conversion is
a few dozen lines of local JavaScript, so there is no upload, no queue and no server log with
your payload in it. Large documents are limited only by the memory of the tab, and a failed
parse prints the parser's first error line above the panes instead of failing silently.
Pick two spaces, four spaces or a tab for the indentation, copy the result, and paste it
straight into the fixture, request body or config file it was meant for.
Frequently asked questions
Is my XML uploaded to a server?
No. The document is parsed with the browser's own DOMParser and converted to JSON by a script already on the page, so nothing leaves your machine. You can load the page, drop the network connection, and keep converting. That matters when the XML is a SOAP payload holding customer records or an API key.
What happens to XML attributes in the JSON output?
Every attribute becomes a key prefixed with an at sign, so id="1" turns into "@id": "1" in the output. The prefix keeps attributes from colliding with child elements that happen to share the same name, and it keeps the mapping reversible, so a JSON to XML pass can put those attributes back exactly where they came from.
How are repeated tags handled?
Two or more sibling elements with the same tag name collapse into a JSON array under that name. A single occurrence stays a plain object or string, because the converter reads structure from the document rather than from a schema. If your consumer always expects an array, normalize that one field after converting.
Why is a numeric value quoted as a string?
XML has no types of its own. Everything between two tags is text, so 1965 arrives as the string "1965" rather than a number, and the converter does not guess. Guessing quietly breaks version strings, zip codes and identifiers with leading zeros, so cast the fields you know are numeric in your own code after converting.