JSON to XML with clear rules

Arrays become repeated elements, "@" keys become attributes, and anything XML cannot express directly is reported instead of guessed.

XML

Compact rules applied
<?xml version="1.0" encoding="UTF-8"?>
<order id="SO-10442" status="confirmed">
  <customer>
    <name>Asha Rao</name>
    <city>Pune</city>
  </customer>
  <line sku="KB-87" qty="2">49.90</line>
  <line sku="MS-03" qty="1">19.00</line>
  <paid>true</paid>
  <note/>
</order>

Conversion notes

  • Numbers, booleans and null became text; XML has no value types without a schema.

Conversion rules

An object with one key becomes the root element; otherwise everything is wrapped in a root element you name. Keys starting with "@" become attributes, "#text" becomes the element’s text, arrays become repeated elements with the same name, null becomes an empty element, and numbers and booleans become text.

Keys that are not valid XML names (such as "1st" or "first name") stop the conversion with their JSON path, unless you allow BeautifyXML to replace invalid characters, which is then listed in the findings. JSON produced by the ordered XML→JSON profile is recognised and converted back exactly.

Questions

How are special characters handled?

Text and attribute values are escaped for their context (&amp;, &lt;, and &quot; in attributes), and the output is parsed again before it is shown.

Can I set the root element name?

Yes. The root and array item names are options; they are only used when the JSON does not already have a single top-level key.