curly{bits}

curlybits / JSON to XML

JSON to XML Converter

Paste JSON to get well-formed XML. Objects become elements, arrays become repeated elements, and keys starting with @ become attributes. Names that aren't valid in XML are fixed for you.

Input JSON
XML output

      

How to use the JSON to XML Converter

  1. Paste JSON into the left box, or click Load sample.
  2. The XML appears on the right as you type.
  3. Set the Root element name. It's used when the JSON has more than one top-level key, or is an array.
  4. Click Copy.

How JSON maps to XML

XMLJSON
<name>Ann</name>"name": "Ann"
Attribute id="7""@id": "7"
Text next to attributes or child elements"#text": "…"
The same element repeatedAn array: "item": [ … , … ]
Empty element <note/>"note": null

This is the common "@ and #text" convention used by many libraries, so the JSON converts back to the same XML with the other tool.

Names that aren't valid XML

XML element names can't start with a digit or contain spaces. Keys like "2024" or "first name" become _2024 and first_name. Special characters in values are escaped, so & becomes &amp;.

Frequently asked questions

Is my JSON uploaded?

No. The conversion runs in your browser.

How do I make an attribute?

Start the key with @: {"item": {"@id": 7, "#text": "Tea"}} becomes <item id="7">Tea</item>.

What happens to arrays at the top level?

Each item becomes an <item> element inside the root.

Updated

Add this JSON to XML converter to your website

Free for blogs, schools and businesses. Copy the code below and paste it into your page's HTML. The tool works exactly like this one and runs in your visitors' browsers, so nothing is uploaded. Please keep the credit line so others can find it too.

Preview embed ↗