JSON to XML
Convert JSON data to XML markup.
Last updated: August 2026
Was this tool helpful?
Mapping JSON into XML markup
JSON and XML both describe structured data, but they disagree on the basics. JSON has objects, arrays, numbers, booleans, and null. XML has only elements, attributes, and text, with no native idea of a list or a number type. A JSON-to-XML conversion has to invent conventions to bridge that gap, which is why two converters rarely produce identical output from the same input.
When this comes up
You usually need it when a modern service speaks JSON but has to feed a legacy consumer: a SOAP endpoint, an enterprise message bus, an older bank or government API, or an XSLT pipeline that only understands XML. Config migration is another case, moving a settings file into a toolset that expects XML.
Example
JSON input:
{
"book": {
"id": 7,
"tags": ["sci-fi", "classic"]
}
}A common XML rendering:
<book>
<id>7</id>
<tags>sci-fi</tags>
<tags>classic</tags>
</book>Where the mapping gets awkward
Arrays are the first headache. JSON says "two tags"; XML just repeats the element, so you lose the explicit grouping unless you wrap it in a parent like <tags>. Keys that start with a digit or contain spaces are not legal XML element names and must be escaped or rejected. And since everything becomes text, the number 7 and the string "7" look the same once converted, so type information is gone unless you add attributes to carry it.
FAQ
What happens to a top-level array? XML needs exactly one root element, so an array at the top must be wrapped in a synthetic root like <root> before each item is emitted.
How is null represented? There is no standard. Some converters emit an empty element, others add xsi:nil="true". Decide with the consumer so an empty tag is not misread as an empty string.
Can I get the JSON back later? Not losslessly through a naive round trip, since repeated elements and dropped types do not reconstruct cleanly. The XML to JSON tool handles the reverse with its own set of conventions.