JSON to XML Converter
Convert JSON payloads into well-formed XML.
Modern APIs speak JSON. A lot of the systems they eventually have to talk to — an enterprise SOAP service, a legacy import job, an old EDI pipeline — still only accept XML. This converter bridges that gap, but it is worth understanding upfront that the two formats do not map onto each other perfectly.
The honest limitation: this conversion is lossy
JSON and XML were built around different ideas of what data looks like, and translating between them means making choices, not just reformatting. XML has attributes as well as elements, and a converter has to decide where a JSON key becomes an element and where it becomes an attribute — there is no single correct answer, only a convention.
JSON, on the other hand, has native arrays and real types: numbers, booleans, and null are distinct from strings. XML has none of that built in — every value is text until something outside the XML itself, such as a schema, says otherwise. Converting JSON to XML means every 42 and every true becomes plain text, indistinguishable from the string "42" or "true" unless you attach a schema to say what it should be.
Choices a JSON-to-XML conversion has to make
- Repeated array items — usually become sibling elements with the same tag name, since XML has no native array construct to mark a list explicitly.
- Object keys — become child elements by default; some converters offer an option to turn certain keys into attributes instead, closer to typical hand-written XML.
- A JSON key starting with a number or containing a space — is not a legal XML element name, so it has to be sanitised or renamed.
- Null values — commonly become an empty element or a self-closing tag, since XML has no direct equivalent of JSON’s
null. - The root element — JSON has no single top-level wrapper requirement; XML insists on exactly one root, so the converter has to invent one, often called something generic like
root.
A small example
| JSON | XML |
|---|---|
{"user": {"id": 42, "active": true}} | <user><id>42</id><active>true</active></user> |
{"tags": ["a", "b"]} | <tags>a</tags><tags>b</tags> |
{"note": null} | <note/> |
JSON to XML questions
Will converting to XML and back give me the same JSON?
Not reliably. Types are the main casualty — a number and a numeric string look identical once they have passed through XML, so a round trip can turn 42 into "42" unless a schema is used to restore the original types.
How are JSON arrays represented, since XML has no array type?
By repeating an element with the same tag name once per array item. This is a convention, not part of the XML specification, so different tools may format the same array slightly differently.
Can I add XML attributes instead of only elements?
Some converters support a special key convention, often prefixing a JSON key with something like @ to mark it as an attribute rather than a child element, rather than trying to infer which should be which.
Does the output include an XML declaration?
Typically yes, a line such as <?xml version="1.0" encoding="UTF-8"?> at the top, since most XML consumers expect one even though it is technically optional for well-formed documents.
Is my JSON sent to a server for this?
Yes, your JSON is sent to the server for conversion, but it is not stored; see our privacy policy for details.