Convert JSON to XML

Turn JSON into an XML document.

0 lines · 0 characters

0 lines · 0 characters

Results update as you type.

Runs in your browser. Nothing uploaded.

How to convert JSON to XML

  1. Paste your JSON into JSON. Start a key with @ to make it an attribute.
  2. Set Root element to the name your XML should be wrapped in. It's only used when the JSON doesn't already have a single top-level key.
  3. Copy the XML or download it as a .xml file.

Conversion rules

JSON XML
{"order": {...}} <order>...</order> as the root
"name": "Ada" <name>Ada</name>
"@id": "A-1042" id="A-1042" on the parent element
"item": [{...}, {...}] Two <item> elements
"note": null <note/>
{"a": 1, "b": 2} Wrapped in <root>

The output starts with <?xml version="1.0" encoding="UTF-8"?> and is indented with 2 spaces. Paste it into the XML formatter if you need 4.

Keys that can’t be element names

JSON keys can be any string, but XML element names can’t contain spaces, can’t start with a digit and can’t start with most punctuation. The converter uses keys exactly as they are, so a key like “first name” or “2fa” produces XML that other tools will reject. Rename those keys in the JSON first, for example to firstName and twoFactor.