Paste any JSON object or array and instantly convert it to well-formed XML. Set your own root element name, then copy or download the result.
JSON and XML both represent structured data, but use different syntax. This converter maps each JSON type to an equivalent XML construct:
| JSON type | XML output |
|---|---|
Object {} |
Wrapping element with child elements for each key |
Array [] |
Repeated sibling elements with the parent key as the tag name |
| String | Text content inside an element |
| Number / Boolean | Text content inside an element |
null |
Self-closing element with nil="true" attribute |
Input JSON:
{
"user": {
"name": "Alice",
"active": true,
"roles": ["admin", "editor"]
}
}
Output XML:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<user>
<name>Alice</name>
<active>true</active>
<roles>admin</roles>
<roles>editor</roles>
</user>
</root>
String values are automatically escaped: & → &, < → <, > → >, " → ", ' → '. The output is always well-formed XML.
JSON keys become XML element names. If a key starts with a digit or contains characters not valid in XML element names, it is sanitized by prefixing with an underscore or replacing invalid characters with underscores.
Does JSON to XML conversion lose any data?
The data is preserved, but some structural information differs. JSON arrays become repeated sibling elements with the same tag name. If you need to round-trip back to JSON exactly, you'd need a schema or convention to distinguish "repeated element" from "array."
Can I convert any JSON, not just objects?
Yes. Arrays at the root level are supported — each item becomes a child element of the root tag. Primitive values at the root are also handled.
Is my data sent to a server?
No. All conversion runs locally in your browser. Nothing you paste leaves your device.
What is the root element for?
XML requires a single root element wrapping everything. You can set it to any valid XML element name — root, data, response, or whatever fits your use case.
Can I convert XML back to JSON?
Not with this tool currently. For the reverse direction, you'd need an XML-to-JSON converter.
Is the output valid XML?
Yes. The converter produces well-formed XML with a standard <?xml?> declaration and properly escaped content.
This website may contain affiliate links. If you click on an affiliate link and make a purchase, we may receive a small commission at no additional cost to you.