XML to JSON Converter
Turn an XML document, feed or SOAP response into JSON you can use in JavaScript or an API.
Convert XML to JSON Online
JSON is easier to work with in JavaScript, in most APIs and in NoSQL databases, but a lot of data still arrives as XML: SOAP responses, RSS feeds, sitemaps, invoices and configuration from older systems. This page is the JSON Converter with XML in and JSON out.
The XML is read by the parser built into your browser, so the document never leaves your device.
An example
The XML <book id="b1"><title>Clean Code</title><price>32.5</price></book> becomes {"book": {"@id": "b1", "title": "Clean Code", "price": 32.5} }. The attribute kept its @, and the price became a number because type detection is on.
What the converter does with each part
| XML | JSON |
|---|---|
| Element with only text | A string, or a number or boolean when detected |
| Attribute | A key starting with @ |
| Repeated element | An array |
| Text next to children or attributes | A #text key |
| Empty element | An empty string |
| Comments and processing instructions | Dropped |
Namespaces
Prefixed names such as soap:Body are kept exactly as written, prefix included, so they are easy to find in the JSON. Namespace declarations are ordinary attributes and appear as @xmlns:soap.
Related conversions
To go back, use JSON to XML; it reads the same @ and #text convention. To view the result as a collapsible tree, paste it into the JSON formatter.