Dad’s Data formats tools

JSON → XML

Convert JSON to XML with proper escaping and structure. 100% local.

JSON Input
Root tag
XML Output

Paste JSON to convert it to XML.

JSON to XML Mapping

XML requires a single root element (no root arrays or primitives). JSON objects become XML elements; their keys become child element names. The root tag name is configurable (defaults to root). Arrays produce repeated sibling elements with the same tag name — derived from the array key.

Input
{
  "library": {
    "name": "City Library",
    "books": [
      { "id": 1, "title": "Clean Code", "author": "Robert Martin" },
      { "id": 2, "title": "The Pragmatic Programmer", "author": "Hunt & Thomas" }
    ],
    "open": true,
    "rating": 4.8,
    "notes": null
  }
}
Output
<?xml version="1.0" encoding="UTF-8"?>
<root>
  <library>
    <name>City Library</name>
    <books>
      <item>
        <id>1</id>
        <title>Clean Code</title>
        <author>Robert Martin</author>
      </item>
      <item>
        <id>2</id>
        <title>The Pragmatic Programmer</title>
        <author>Hunt &amp; Thomas</author>
      </item>
    </books>
    <open>true</open>
    <rating>4.8</rating>
    <notes/>
  </library>
</root>

Type Mapping Reference

JSON typeXML representationNotes
String<key>value</key>Special chars (<, >, &, ", ') are escaped
Number<key>42</key>Written as text content
Boolean<key>true</key>Written as text content
null<key/>Self-closing empty element
ObjectNested child elementsObject keys become element names
ArrayRepeated sibling elementsEach element uses the array key (or item)
Warning: XML element names cannot start with a number or contain spaces. If your JSON keys have spaces or start with digits, the converter will sanitize them (spaces → underscores, prepend underscore for digit-start).

Root Tag and Document Structure

Every XML document needs a single root element. By default this is root. Change the root tag to match your target schema — for example, feed for Atom, rss for RSS, or users if your top-level JSON object represents a user list. The generated XML always includes the XML declaration <?xml version="1.0" encoding="UTF-8"?>.

Frequently Asked Questions

Your files stay on your computer. Dad promised.

Data formats tools

Search the Data formats tools