JSON to XML Converter
Convert JSON to XML and XML to JSON online. Attributes, arrays and nested elements are handled correctly, with clear error messages. Free and browser-based.
Convert between JSON and XML
Many systems still speak XML: SOAP services, RSS feeds, banking interfaces, Android resources and older enterprise software. Modern APIs and front ends mostly use JSON. This two-way converter sits between them, turning JSON into well-formed XML and XML back into JSON, so you can inspect or reuse data from either side.
XML input is validated before conversion. If a tag is left open or an attribute is malformed, you get an error message rather than a silently wrong result.
How the mapping works
JSON and XML do not line up exactly, so a converter has to follow some conventions. These are the ones this tool uses:
- A key that starts with
@_becomes an attribute, so"@_id": "1001"turns intoid="1001". - A
#textkey holds the text of an element that also has attributes. - An array becomes repeated elements that share the same tag name.
- If your JSON has more than one top-level key, or is an array, a
rootelement is added because XML allows only one root. - When reading XML, numbers and booleans are converted to real JSON types. Turn that option off to keep every value as a string.
Example
A small order with an attribute and a repeated element. Converting the output back gives you the original structure.
{ "order": { "@_id": "1001", "item": ["pen", "ink"], "paid": true } }
<?xml version="1.0" encoding="UTF-8"?>
<order id="1001">
<item>pen</item>
<item>ink</item>
<paid>true</paid>
</order>When a round trip changes your data
XML has no array type. A single <item> element becomes a plain value in JSON, while two of them become an array, so code that reads the result should accept both shapes. Element order and mixed text content can also shift, since JSON objects are not designed to preserve them. Check the output before relying on it in a production pipeline.
Frequently Asked Questions
How do I create an XML attribute from JSON?
Prefix the key with @_. For example { "book": { "@_id": "b1", "title": "APIs" } } produces <book id="b1"> with a title child element.
Why did a list with one item stop being an array?
XML cannot mark something as a list, so one element looks the same as a single value. Only repeated elements can be recognised as an array.
Why are my numeric IDs changing type?
With the number option on, a value like 42 becomes a JSON number. Turn the option off if your IDs must stay as strings. Values with leading zeros, such as 007, are kept as strings either way.
What happens to invalid XML names?
Characters that XML does not allow in tag names are replaced during conversion so the output stays well-formed. Check the tag names if your JSON keys contain spaces or start with a digit.