XML to JSON: Attributes and Repeated Nodes
XML has attributes, mixed content and repeated elements that JSON has no direct equivalent for. Here is exactly how each one is mapped.

Converting XML to JSON is not a lossless translation. XML is a document format with attributes and mixed content; JSON is a data format with keys and arrays. A good converter picks a consistent mapping and sticks to it.
Attributes get an @ prefix
An attribute cannot collide with a child element, so it is stored as `@name`. The element `<item id="7">` becomes `{ "@id": "7" }` inside its parent object.
Repeated elements become arrays
Two `<item>` siblings cannot both be the key `item`, so the converter promotes the key to an array. One item stays an object; two or more become an array. If your code expects a list, normalise after parsing.
Text next to child elements
Mixed content such as `<p>Hello <b>world</b></p>` has text and elements at the same level. The text is stored under `#text` so it is not silently discarded.
How to convert
- 1Open the XML to JSON tool.
- 2Paste the XML — namespaces are kept in element names.
- 3Convert and inspect the first node to confirm the attribute convention.
- 4Validate the output with the JSON Validator.
Frequently asked questions
Are namespaces preserved?
Element names keep their local name. Namespace URIs are not included, so two elements with the same local name from different namespaces will collide.
Can I convert JSON back to XML?
Not with this tool. Round-tripping is lossy in both directions; keep the original XML if you need to preserve it.
Why is my number a string?
XML has no number type — everything is character data. Cast numeric fields in your application after parsing.
Do it now — free, no signup
Keep reading
Last updated 10 November 2026. Files processed by FilePlume are deleted automatically; nothing is used for training.