How to convert JSON to XML
- Paste a JSON object or array.
- If the JSON has a single top-level key, it becomes the root element; otherwise everything is wrapped in a root element whose name you can set.
- Keys starting with
@become attributes and a#textkey becomes the element's text, so you can produce XML such as<price currency="USD">9.99</price>. - Copy the XML or download it. An XML declaration is added at the top.
Conversion rules
Each object key becomes a child element. Arrays repeat their parent element name, so {"item": [1, 2]} becomes two <item> elements. Strings, numbers and booleans become text, and null becomes an empty self-closing element. Special characters &, < and > are escaped, and keys that are not valid XML names (for example ones starting with a digit or containing spaces) are made safe with underscores.
This is useful when a legacy system, SOAP service, payment gateway, government API or feed format requires XML but your data lives in JSON, and for producing quick sample files for tests. Check the output against the target's schema, since XML formats often require specific element orders and namespaces.
The conversion runs entirely in your browser.
FAQ
How do I create XML attributes from JSON?
Prefix the key with @, for example {"book": {"@id": "1", "title": "Dune"}} gives
What happens to a top-level array?
It is wrapped in the root element and each item becomes an
Can I add namespaces?
Yes. Use keys such as "@xmlns" or "@xmlns:soap" and prefixed names like "soap:Body".