How to use
- Paste JSON or load the sample.
- Choose the indentation.
- Copy the XML or download it.
Options explained
- Attributes
- Keys that start with @, such as "@id", become attributes; "#text" becomes the element text.
- Arrays
- An array becomes the same element repeated once per item.
- Root element
- XML needs exactly one root. If the JSON is an array or has several top-level keys, everything is wrapped in <root>.
Example
The @id key becomes an attribute, the array becomes repeated item elements and null becomes an empty element. The input has exactly one top-level key, so that key is the root element.
{"order": {"@id": "A1", "customer": "Ada", "item": [{"name": "Pen", "qty": 2}, {"name": "Ink", "qty": 1}], "note": null}}
<?xml version="1.0" encoding="UTF-8"?>
<order id="A1">
<customer>Ada</customer>
<item>
<name>Pen</name>
<qty>2</qty>
</item>
<item>
<name>Ink</name>
<qty>1</qty>
</item>
<note/>
</order>
When the top level is an array, such as [{"a": 1}, {"a": 2}], the result is a root element containing one item element per entry, each holding the a element.
Frequently asked questions
Are invalid element names fixed?
No. Keys with spaces or starting with a digit are not valid XML names; rename them in the JSON first.
How are null values written?
As empty elements, such as <middleName/>.
Can I convert the XML back?
Yes. Use XML to JSON; with the same @ and #text conventions the round trip keeps attributes and text.
Privacy
This tool runs entirely in your browser. Your files and text are processed on your device and are never uploaded to our servers.