Convert JSON into well-formed XML with a clear, deterministic mapping — processed entirely in your browser.
Your XML will appear here after you convert.
JSON and XML both describe structured data, but XML adds concepts JSON doesn’t have — attributes, namespaces, and comments — while JSON has a compact object/array model. This tool converts JSON into well-formed XML using a clear, deterministic mapping.
{
"user": {
"name": "John",
"roles": ["admin", "editor"]
}
}<?xml version="1.0" encoding="UTF-8"?>
<root>
<user>
<name>John</name>
<roles>
<item>admin</item>
<item>editor</item>
</roles>
</user>
</root><item> elements inside the key’s element, so ordering and count are preserved.null and empty objects/arrays become empty elements (<tag/>).root) wraps the document, with an optional XML declaration.Because XML and JSON aren’t identical models, the conversion is deterministic rather than perfectly reversible: JSON keys that aren’t valid XML names have invalid characters replaced with _, and XML-only features (attributes, namespaces) are not produced from plain JSON. To go back, use XML to JSON; to tidy the input, use the JSON Formatter.
Object keys become elements, arrays become repeated <item> elements inside the key's element, and primitive values become escaped text nodes. A configurable root element wraps everything (default <root>).
An array value becomes a container element holding one <item> per element. For example {"users":[{"name":"A"}]} becomes <users><item><name>A</name></item></users>, so no array information is lost.
null (and empty objects/arrays) become empty elements such as <name/>. XML has no dedicated null type, so this is the simplest correct representation — a documented limitation.
Yes. Characters like &, <, and > in text are escaped to &, <, and >, so the output is always well-formed XML.
No. XML concepts like attributes, namespaces, and comments have no JSON equivalent, and JSON keys that aren't valid XML names have invalid characters replaced with underscores. The mapping is deterministic and documented rather than lossless in both directions.