← Tools
Conversion

XML to JSON

Convert XML to JSON using the browser's native DOMParser. Handles nested elements, attributes, and repeated tags.

XML Input⚠ DOMParser is not defined
JSON Output

Attributes

When Include attributes is on, element attributes are mapped under an @attributes key. For example <user id="1"> becomes {"@attributes":{"id":"1"}}. Parsing is done via the browser's built-in DOMParser API.

Repeated Tags

When the same tag appears multiple times under a parent, the values are automatically merged into a JSON array — so two <user> elements become "user": [{…}, {…}].

Limitations

  • XML namespaces are preserved as part of the tag name
  • Processing instructions and comments are ignored
  • CDATA sections are treated as text content
  • To format or validate the resulting JSON, use the JSON Formatter