What is JSON to XML?
JSON to XML converts JSON objects and arrays to well-formed, properly escaped XML, with configurable root element names, optional attributes mode, and standard XML entity escaping.
JSON and XML have different data models — JSON has no analog for XML attributes, comments, or processing instructions. The conversion is a structural approximation, not a lossless round-trip.
Conversion Modes
Child Elements
Default mode — each JSON key becomes a child XML element. Most readable for hierarchical data.
Attributes Mode
Simple string and number values become XML attributes. Produces more compact XML.
Array Handling
Arrays produce repeated child elements. Configure the element tag name for each array.
How to Use JSON to XML
Paste JSON
Paste your JSON object or array. The tool validates syntax before converting.
Set root name
Enter the root element name (e.g. 'root', 'data', 'response').
Configure arrays
Set custom tag names for array items if the default 'item' doesn't fit your schema.
Copy XML
Click Copy to grab the formatted XML output.
Conversion Example
Input JSON:
{ "user": { "name": "Alice", "age": 28, "roles": ["admin", "editor"] } }
Output XML (child elements mode):
<?xml version="1.0" encoding="UTF-8"?>
<root>
<user>
<name>Alice</name>
<age>28</age>
<roles>
<item>admin</item>
<item>editor</item>
</roles>
</user>
</root>
Tips & Common Mistakes
XML element names can’t start with numbers. If your JSON keys start with digits (e.g. “1stItem”), the converter prefixes them with an underscore to produce valid XML element names.
Use child elements for complex structures. Attributes mode works well for simple flat objects, but nested objects and arrays always become child elements regardless of mode.
Related Tools
- XML Formatter — beautify and validate the XML output
- JSON Formatter — clean up source JSON first
- JSON Validator — validate before converting