Skip to content
All tools›Converters›XML to JSON Converter

XML to JSON Converter

Convert an XML file into JSON. Attributes are prefixed (@ by default), sequences of similar elements become arrays.

Loading tool...

XML to JSON conversion rules

XML and JSON do not have the same data model. The converter applies deterministic rules:

  • The document becomes an object with a single property named after the root element.
  • An element that contains only text becomes a string. An empty element becomes null.
  • An element with child elements becomes an object.
  • Attributes become properties prefixed with @ (configurable). Text goes into #text.
  • A sequence of two or more sibling elements with the same name becomes a JSON array.
  • Namespace declarations are kept as attributes by default.
  • Comments are dropped unless "Include comments" is checked.
---