How to use the XML to JSON Converter
- 1. Paste XMLA feed, API response or config file.
- 2. Pick optionsThe attribute prefix, and whether to turn numbers and booleans into JSON types.
- 3. Copy the JSONConvert and copy or download the result.
How the XML is mapped
XML and JSON don't line up exactly, so a converter has to choose rules. This one uses the most common conventions:
- Each element becomes a key with its name.
- Attributes become keys with a prefix, @ by default, so
id="1"becomes"@id": 1. - Elements repeated under the same parent become an array.
- An element with only text becomes that value; text next to child elements goes into
#text. - Empty elements become null.
- With type conversion on, 88 becomes a number and true becomes a boolean. Values with leading zeros, like 007 or a PIN code, stay as text.
Worked example
The sample has a students root with a batch attribute, two student elements and a mentor. 8 XML elements are converted, and the result is:
{
"students": {
"@batch": 2026,
"student": [
{ "@id": 1, "name": "Asha", "marks": 88 },
{ "@id": 2, "name": "Rahul", "marks": 74 }
],
"mentor": "Meera"
}
}Because there are two student elements, they become an array. A catch to watch for: if the XML had only one student, it would be a single object, not an array of one. Code that reads converted XML should handle both cases, or always wrap the value in an array.
Frequently asked questions
Can it convert JSON back to XML?
Not in this tool. JSON to XML needs extra choices, like which keys become attributes.
Are namespaces kept?
Element names keep their prefixes, such as soap:Body. Namespace declarations show up as @xmlns attributes.
Why is my PIN code a string?
Values starting with 0 are kept as text so leading zeros are not lost.
Is the xml to json converter free?
Yes, it is free. Your first conversion asks for your name and WhatsApp number once, and after that the xml to json converter and every other Uncodemy tool open without the form.