Skip to content

JSON to XML Converter - Transform JSON to XML Online

Input JSON
XML Output

Convert JSON to XML

Paste JSON on the left and well-formed, indented XML appears on the right with an XML declaration and a root element. Name the root element to match what the receiving system expects. The conversion runs in your browser.

Example

{"id": 7, "first name": "Ann", "tags": ["admin", "ops"], "manager": null}

with the root element set to user, becomes:

<?xml version="1.0" encoding="UTF-8"?>
<user>
  <id>7</id>
  <first_name>Ann</first_name>
  <tags>
    <item>admin</item>
    <item>ops</item>
  </tags>
  <manager />
</user>

The key with a space became first_name, the array became item children, and null became an empty element. If the schema you are targeting wants <tag> instead of <item>, or wants id as an attribute, rename them in the output.

When You Need XML

SOAP web services, many payment and banking integrations, Android string resources and older enterprise systems still take XML. A common job is turning a JSON test fixture or API response into a request body for one of those. To read an XML response back as JSON, use the XML to JSON converter.

Related Tools

Frequently Asked Questions

How does the converter map JSON to XML?
Each key becomes an element and each primitive value becomes its text, with &, < and > escaped. Nested objects become nested elements. An array becomes an element whose children are all named item, so {"tags":["a","b"]} gives <tags><item>a</item><item>b</item></tags>. null, {} and [] become empty elements such as <note />.
Can I turn JSON keys into XML attributes?
No. Every key becomes a child element. If the target system expects attributes, for example <user id="7">, you will need to adjust the output by hand or with an XSLT step.
What happens with keys that are not valid XML names?
Characters other than letters, digits, underscores, hyphens, dots and colons are replaced with underscores, and a name that does not start with a letter or underscore gets a leading underscore. So "first name" becomes first_name and "2fa" becomes _2fa. Keys containing a colon are kept as written, and XML tools will treat the part before the colon as a namespace prefix.
Can I change the root element?
Yes. Type a name in the root element box; it defaults to root. The output always starts with <?xml version="1.0" encoding="UTF-8"?>.
Can I convert XML back to JSON?
Yes, with the XML to JSON converter. A round trip will not give you identical JSON, though: XML has no number or boolean types, so every value comes back as a string, and arrays of one item come back as a single object.