XML to JSON Converter

Convert an XML document to JSON. Each element becomes a JSON object: attributes are kept as @name keys, a tag that repeats inside its parent becomes an array, and an element with only text becomes that text value.

How xml to json works here

  • Attributes are stored under keys prefixed with @ (e.g. <a href="x"> becomes {"@href":"x"}).
  • When a tag appears more than once inside its parent, those elements are collected into a JSON array.
  • An element with only text becomes that string; an element with both text and attributes/children keeps the text under a #text key.

Frequently asked questions

How are attributes and repeated tags represented?
Attributes become @-prefixed keys, and a tag that repeats inside its parent (several <item>) becomes a JSON array. This is the widely used XML-to-JSON convention, so the output is easy to consume in code.
Why is there a #text key sometimes?
When an element has both its own text and attributes or child elements, the text can’t be the element’s whole value, so it is preserved under a #text key instead of being dropped.
Is my XML uploaded anywhere?
No. Parsing happens in your browser via the built-in DOMParser; nothing is sent to a server.

Related data & developer conversions

See all data-format conversions →