XML to JSON
Convert XML elements, attributes and text to a documented JSON tree while blocking external entities.
Your workspace
Server processingThis utility converts XML structures into equivalent JSON objects. It maps XML elements, attributes, and text content into a hierarchical JSON tree, which simplifies data manipulation in modern web applications.
How to convert XML to JSON
- Paste your XML content into the input area.
- The conversion process automatically maps elements to keys and attributes to an @attributes object, generating a JSON representation.
Conversion Logic
The conversion logic treats XML elements as keys. If multiple elements share the same tag name, they are grouped into an array. Attributes are preserved within an @attributes object to prevent naming collisions with child elements.
Conversion Example
<data><id>1</id></data>
{"data": {"id": {"#text": "1"}}}
Questions about XML to JSON
How are attributes handled?
Attributes are stored in an @attributes object within the element's JSON representation.
What happens to text nodes?
Text content is mapped to a #text property within the corresponding element object.