JSON → XML
Convert JSON to XML with proper escaping and structure. 100% local.
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.
{
"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
}
}<?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 & Thomas</author>
</item>
</books>
<open>true</open>
<rating>4.8</rating>
<notes/>
</library>
</root>Type Mapping Reference
| JSON type | XML representation | Notes |
|---|---|---|
| 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 |
| Object | Nested child elements | Object keys become element names |
| Array | Repeated sibling elements | Each element uses the array key (or item) |
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.