JSON to XML Converter
Turn JSON into indented XML for SOAP services, legacy integrations and XML-based config files.
JSON
Convert JSON objects to XML elements
SOAP services, payment gateways, RSS feeds and many enterprise systems still speak XML. This converter maps JSON onto XML in a predictable way: each key becomes an element, an array becomes the same element repeated once per item, and nested objects become nested elements. To produce attributes or mixed text, use the special keys _attributes and _text, which is also the shape the XML to JSON converter produces, so data can make a round trip. The output is indented with two spaces.
How to use
- Wrap your data in a single top-level key, which becomes the XML root element, for example {"order": {...}}.
- Paste the JSON; add an _attributes object wherever an element needs attributes.
- Copy the XML from the output editor.
Frequently asked questions
- Why does my XML have more than one root element?
- Every top-level key in the JSON becomes a top-level element. A well-formed XML document needs exactly one root, so wrap your data in a single key such as {"root": {...}}.
- How do I create XML attributes?
- Add an _attributes object to the element, for example {"book": {"_attributes": {"id": "bk101"}, "title": "Midnight Rain"}} produces <book id="bk101"><title>Midnight Rain</title></book>.
- Is an XML declaration added?
- Not by default. Add a _declaration key, for example {"_declaration": {"_attributes": {"version": "1.0", "encoding": "UTF-8"}}}, at the top level to output <?xml version="1.0" encoding="UTF-8"?>.
Example: JSON to XML
JSON input
{
"order": {
"_attributes": { "id": "1042" },
"customer": "Ada Lovelace",
"item": [
{ "sku": "BK-01", "qty": 2 },
{ "sku": "PN-07", "qty": 1 }
]
}
}XML output
<order id="1042">
<customer>Ada Lovelace</customer>
<item>
<sku>BK-01</sku>
<qty>2</qty>
</item>
<item>
<sku>PN-07</sku>
<qty>1</qty>
</item>
</order>