XML to JSON Converter

Convert XML to JSON format instantly. Handles attributes, nested elements, and repeated tags automatically.

How XML Maps to JSON

The converter follows a standard convention for mapping XML to JSON:

  • The root XML element becomes the top-level JSON key
  • Child elements become nested JSON object properties
  • XML attributes are placed in an @attributes object
  • Repeated sibling elements with the same tag name become a JSON array
  • Text-only elements become string values

Example

Input XML:

<book id="1">
  <title>JSON Handbook</title>
  <tag>api</tag>
  <tag>data</tag>
</book>

Output JSON:

{
  "book": {
    "@attributes": { "id": "1" },
    "title": "JSON Handbook",
    "tag": ["api", "data"]
  }
}

To go the other direction, use JSON to XML Converter. Or validate the output with JSON Validator.

Frequently Asked Questions

How are XML attributes handled in the JSON output?

XML attributes are placed in an @attributes object inside the element's JSON representation. For example, <user id="1"> becomes { "user": { "@attributes": { "id": "1" } } }.

How are repeated XML elements converted?

Repeated sibling elements with the same tag name are automatically converted to a JSON array. Three <role> elements become "role": ["admin", "editor", "viewer"].

Is my XML data sent to a server?

No. All conversion happens entirely in your browser. Your data never leaves your device.