XML to JSON
Convert XML into clean JSON. Repeated elements become arrays, attributes are kept with an @ prefix, and numbers can be typed automatically.
Or paste the content instead
How the conversion works
- Elements become object keys; elements that repeat become arrays.
- Attributes are kept with an
@prefix, e.g."@id": 1. - Text next to attributes is stored under
"#text". - Types: with conversion on,
42becomes a number andtruea boolean. Codes with leading zeros, like007, stay as text.
How to use the XML to JSON: step by step
- Choose an XML file, or paste XML.
- Decide whether to keep attributes, convert numbers and true/false, and pretty-print.
- Click convert.
- Copy or download the JSON.
A real example
An old API returns <book id="7"><title>Dune</title><year>1965</year></book>. The JSON becomes {"book": {"@id": 7, "title": "Dune", "year": 1965}}, easy to use in JavaScript.
Tips for better results
- Elements that repeat become arrays automatically.
- Text next to attributes is stored under
#text. - Turn off number conversion if values like ZIP codes have leading zeros.
More questions
Why did my ZIP code lose its leading zero?
“Convert numbers” turned it into a number. Turn that option off to keep values as text.
Is it private?
Yes, nothing leaves your device.
Frequently asked questions
Is my file uploaded anywhere?
No. The file is read and converted by your own browser, so it never leaves your device. That makes it safe for customer lists, finances and other private data.
Why is a single element not an array?
An element that appears once becomes a plain value; it becomes an array only when it repeats. If your code always expects arrays, check for both cases.
Are namespaces supported?
Yes. Prefixed tags like media:content are kept as key names exactly as written.