XML To JSON

Convert XML into JSON

Convert XML documents (RSS feeds, SOAP responses, config files) into JSON. Attributes are kept with a prefix, values can be type-converted, namespaces stripped, and invalid XML is pinpointed.
Try an example:

Output will appear here...

About XML To JSON

How it works

  1. The XML is first validated; any error is reported with its line, column and the surrounding lines.
  2. Each element becomes a JSON key; repeated elements become arrays; text content becomes the value.
  3. Attributes become keys with your prefix (e.g. "@id"). Numbers and booleans are converted unless you turn that off.

What you need

  • Well-formed XML (every tag closed, one root element).

Tips

  • Strip namespaces to get clean keys from SOAP and RSS documents.
  • Turn off value conversion to keep IDs like 007 as text.

Limitations

  • Mixed content (text and elements side by side) and comments are simplified.

Runs in your browser. Everything happens in your browser - your code and data are never uploaded.

Frequently asked questions

Why is a single child not an array?+

XML does not say whether an element can repeat. One <tag> becomes a value; two or more become an array. Code reading the JSON should handle both.