XML to JSON Converter
Convert XML to JSON online, free. Handles attributes, nested elements, and repeated tags as arrays. Fully client-side — no upload or account needed.
By Utilix Editorial Team · Added Sep 22, 2026
Input
Result
Enter a value for xml to see your result.
How it works
Converts XML markup into a JSON object entirely in your browser. Attributes become @-prefixed keys, repeated sibling elements collapse into arrays, and mixed text content is kept under a #text key — a common, tool-agnostic XML-to-JSON convention.
Step by step
- 01Paste well-formed XML into the input box.
- 02Element attributes become keys prefixed with @ (e.g. @id).
- 03Sibling elements sharing the same tag name become a JSON array.
- 04Leaf elements with no attributes become plain string values; if attributes are present, text content is kept under #text.
Examples
Single record with an attribute
The id attribute becomes @id; child elements become nested keys.
Inputs
- XML:
- <user id="1"><name>Alice</name><age>30</age></user>
- Pretty-print (2-space indent):
- true
Result
- JSON output:
- { "user": { "@id": "1", "name": "Alice", "age": "30" } }
Frequently asked questions
How are XML attributes represented in the JSON output?
Each attribute becomes a key prefixed with @, e.g. <user id="1"> becomes { "@id": "1" }. This is a widely used XML-to-JSON convention that keeps attributes distinguishable from child elements.
What happens to repeated elements, like multiple <item> tags?
Sibling elements that share the same tag name are collapsed into a JSON array, so <items><item>A</item><item>B</item></items> becomes { "item": ["A", "B"] }.
Are number and boolean values converted automatically?
No — all XML text content is kept as strings, since XML itself has no type system. Cast values in your own code after conversion if you need numbers or booleans.