CodeUtils
Loading…

Convert XML documents into JSON objects or vice versa. Handles attributes, nested elements, and repeated sibling nodes automatically.

Use Cases

  • Converting legacy SOAP or RSS XML responses to JSON for modern APIs
  • Transforming JSON config data back to XML for Java or .NET systems
  • Bridging data between systems that use different serialisation formats
  • Flattening XML attribute maps into JSON key-value pairs

Example

Input
<user id="42"><name>Alice</name><role>admin</role></user>
Output
{
  "user": {
    "@id": "42",
    "name": "Alice",
    "role": "admin"
  }
}

FAQ

How are XML attributes handled in JSON output?

Attributes are prefixed with @ by convention, so id becomes @id in the JSON result.

What happens with repeated XML elements?

Repeated sibling elements with the same tag are converted to a JSON array automatically.