XML to JSON Converter
Paste XML or JSON, pick a direction, and see the converted result immediately — useful for reading a SOAP/REST response as JSON, or turning a JSON config back into XML for a system that expects it.
Overview
XML and JSON both describe structured, nested data, but XML also carries attributes and text content alongside child elements, which JSON has no built-in concept of. This tool uses a consistent, documented mapping: element attributes become JSON keys prefixed with `@` (e.g. `@id`), an element's own text becomes a `#text` key when it also has attributes or children, and an element name that repeats among its siblings becomes a JSON array instead of overwriting itself.
Converting JSON back to XML reverses the same mapping, so a value converted from XML and immediately converted back produces equivalent XML. The JSON side does require exactly one top-level property, since XML always has exactly one root element.
Examples
XML to JSON
<person id="1"><name>Alice</name><age>30</age></person>
{
"person": {
"@id": "1",
"name": "Alice",
"age": "30"
}
}
JSON to XML
{"person": {"@id": "1", "name": "Alice", "age": "30"}}
<?xml version="1.0" encoding="UTF-8"?> <person id="1"> <name>Alice</name> <age>30</age> </person>
How It Works
- Paste your XML or JSON into the input box.
- Choose the direction: XML to JSON, or JSON to XML.
- Click Convert to see the result — switch direction at any time without losing your input.
Use Cases
Reading a SOAP or legacy XML API response
Convert an XML response to JSON to work with it more easily in JavaScript or to compare it against a REST equivalent.
Turning a JSON config into XML
Some tools (build configs, legacy enterprise systems) still expect XML — write the config as JSON and convert it back before saving.
Tips
- Repeated sibling elements with the same tag name become a JSON array automatically; a tag that appears only once stays a plain nested object, so adding a second occurrence later changes the JSON shape.
- An XML element with both attributes and text content (not just child elements) converts to an object with `@`-prefixed attribute keys plus a `#text` key for the text.
FAQ
No. Conversion happens entirely in your browser using the native DOMParser API and hand-written JSON mapping — nothing you paste ever leaves your device.
The tool shows a specific error message — an XML parser error description, or a JSON syntax error — instead of guessing at a fix or showing partial output.
As object keys prefixed with `@`, e.g. the XML attribute `id="1"` becomes the JSON key `"@id": "1"`.
XML documents always have exactly one root element, so the JSON's single top-level key becomes that root element's tag name.