Advertisement

XML to JSON

Convert XML to JSON free, in seconds. Paste your XML, press Convert, and get clean JSON with attributes preserved.

XML input

Paste your XML below, then press Convert.

Paste XML above to begin.
Advertisement

How XML maps to JSON

Elements become object keys; repeated sibling elements become arrays. Attributes are kept with an @ prefix (or merged plain), and mixed text lands under #text. The mapping is deterministic, so converting the same XML twice gives the same JSON.

Namespaces and edge cases

Namespace prefixes are kept as part of element names (for example soap:Body). CDATA sections are treated as text. Comments and processing instructions are skipped. Very deep documents convert fine, but extremely large files may take a moment.

XML to JSON FAQs

Why do attributes get an @ prefix?
To distinguish them from child elements with the same name. You can switch to plain merge if your XML has no such collisions.
Why did repeated elements become an array?
JSON needs a way to hold several same-named children. A single child stays an object; two or more become an array.
What happens to XML comments?
They are skipped. Only elements, attributes, text and CDATA make it into the JSON.
Can I convert back to XML?
Yes. Use the JSON to XML converter on this site for the reverse trip.
Is my data sent to a server?
No. Parsing and conversion run entirely in your browser.
Advertisement