XML to JSON Converter

Convert XML to JSON, keeping attributes, repeated elements and text.

How is XML converted to JSON?

XML to JSON conversion reads an XML document and represents each element as a JSON property, repeated elements as arrays and attributes as prefixed keys, so XML feeds and APIs can be used easily in JavaScript.

Conversion rules

  • Elements become properties with the same name.
  • Attributes become keys with an @ prefix, e.g. "@id": "1".
  • Repeated sibling elements become arrays.
  • Text inside an element with attributes or children is stored as #text.
  • The root element is kept as the top-level key.

The XML is parsed with the browser's standards-compliant parser, so malformed XML is reported with an error message instead of producing wrong JSON. Common uses include RSS feeds, sitemaps, SOAP responses and product feeds.

Frequently asked questions

Are XML namespaces supported?

Yes, prefixed element and attribute names are kept as they are, e.g. "xhtml:link".

Why is a single element not an array?

Elements become arrays only when they repeat. A single child is a plain value.

Is my XML uploaded?

No, it is converted in your browser.