XML to JSON Converter

Convert XML to JSON: elements become keys, attributes become @-prefixed keys and repeated elements become arrays. Switch direction to go from JSON back to XML (or open the dedicated JSON to XML converter). Runs 100% in your browser.

XML input

JSON output

attr

How JSON maps to XML

JSONXML
{"title": "Guide"}<title>Guide</title>
{"book": {"@id": "b1"}}<book id="b1"/>
{"note": {"@lang": "en", "#text": "Hi"}}<note lang="en">Hi</note>
{"tag": ["a", "b"]}<tag>a</tag><tag>b</tag>
{"empty": null}<empty/>
  • This mapping is lossy: comments and processing instructions are dropped, text is trimmed, and mixed text/child ordering is not preserved. Repeated siblings are grouped, so their original order relative to other names is lost.
  • JSON names may be normalized to XML names. Empty arrays disappear, and null, empty text and empty elements cannot always be distinguished when converting back.
  • XML has no data types: numbers and booleans become text in XML, and are detected again when converting back to JSON.
  • A single repeated element can't be told apart from a single object, so one <book> becomes an object and two become an array.

FAQ