Developer Tools
JSON to XML Converter
JSON to XML Converter is part of Toolspire and is ready as soon as this page loads. Turn JSON into clean, valid XML — attributes from “@” keys, repeated or wrapped arrays, CDATA and your own root element. Converts as you type, entirely in this tab.
On this page
What you can do here
Attributes and text
Write {"price": {"@currency": "INR", "#text": "799"}} and get <price currency="INR">799</price> — exactly what most XML APIs expect.
Your array style
Repeat the element for each entry, or wrap entries in item elements — whichever the receiving system wants.
Always valid XML
Invalid names are fixed, special characters escaped, mixed content kept on one line and empty arrays handled, with a note for every change.
Round-trips
Switch to XML → JSON at any time: the result converts straight back, so you can edit data as JSON and send it as XML.
Exact numbers
IDs and amounts like 12345678901234567890 or 1.50 are written exactly as in the JSON, never rounded.
Private
API payloads and configs stay on your device. No upload, no account.
The sequence
How to convert JSON to XML
- 1
Paste the JSON
Paste JSON into the left box, open a .json file, or try the Sample.
- 2
Set the options
Open Options to choose the root and item element names, how arrays are written, CDATA and the XML declaration.
- 3
Check the result
The XML appears as you type, with notes about anything that was renamed, wrapped or removed.
- 4
Copy or download
Click Copy, or Download to save an .xml file.
Worth knowing
- JSON to XML Converter on Toolspire: keys starting with @ become attributes and #text becomes element text — the same convention as the XML to JSON converter, so data round-trips.
- Arrays can repeat the element (
<tag>a</tag><tag>b</tag>) or wrap each item (<tags><item>a</item>…</tags>), and nested arrays always produce valid XML. - Data without a single root is wrapped in a root element you can name; top-level arrays get one item element per entry.
- Keys that aren’t valid XML names are fixed (“first name” →
first_name, “2nd” →_2nd) and listed, and characters XML can’t hold are removed and reported. - Options for the XML declaration, CDATA sections, self-closing empty elements and 2-space, 4-space, tab or minified output.
- Accepts relaxed JSON (comments, trailing commas, single quotes) and points to the exact line and column of real errors. Big numbers keep every digit.
- Runs entirely in this tab — the JSON is not sent to us.
How JSON maps to XML
| JSON | XML |
|---|---|
{"user": {"name": "Asha"}} | <user><name>Asha</name></user> |
{"user": {"@id": "7"}} | <user id="7"/> |
{"price": {"@currency": "INR", "#text": 799}} | <price currency="INR">799</price> |
{"list": {"tag": ["a", "b"]}} | <list><tag>a</tag><tag>b</tag></list> (or wrapped: <list><tag><item>a</item><item>b</item></tag></list>) |
{"note": null} | <note/> |
[1, 2] | <root><item>1</item><item>2</item></root> |
Good to know
XML has no data types, so numbers, booleans and null all become text: true is written as <paid>true</paid>. An empty array can’t be shown with repeated elements, so it is left out (with a note) unless you choose Wrap items.
Converting the other way? Use the XML to JSON converter. To check or tidy JSON first, try the JSON Formatter.
FAQ
Questions about JSON to XML Converter
Where does JSON to XML Converter run?
How do I convert JSON to XML?
How do I make an XML attribute from JSON?
{"book": {"@id": "42", "title": "Gitanjali"}} becomes <book id="42"><title>Gitanjali</title></book>. You can change the prefix under Options.How are JSON arrays converted?
"tag": ["a","b"] gives two <tag> elements. Choose Wrap items to get <tag><item>a</item><item>b</item></tag> instead, and set the item element’s name.Why was my data wrapped in <root>?
Can it convert invalid JSON?
Is my JSON uploaded?
Keep going
Related tools
Last updated Report a problem or suggest a feature