JSON to XML Converter

Convert JSON objects into structured XML.

What This Tool Does

This tool converts a JSON value into an XML document. The entire output is wrapped in a single <root> element, preceded by the standard <?xml version="1.0" encoding="UTF-8"?> declaration, so you always get one valid, well-formed document.

Object keys become element names directly: {"name": "Ada"} becomes <name>Ada</name>. Nested objects recurse the same way, producing nested elements rather than flat text. Arrays are handled based on where they appear: an array nested inside an object is expanded into repeated elements that reuse the surrounding key name (so "tags": ["a","b"] becomes <tags>a</tags><tags>b</tags>), while an array at the very top level of your pasted JSON — with no key to reuse — has each of its entries wrapped in a generic <item> element instead.

Text values are escaped for XML safety: &, <, >, ", and ' are converted to their entity equivalents (&amp;, &lt;, &gt;, &quot;, &apos;) so the output stays valid XML even if a string contains markup-like characters. null and undefined values are rendered as an empty element, e.g. <note></note>.

How to Use It

  1. Paste any valid JSON — an object, an array, or a plain value — into the Input box on this page.
  2. Click Run to convert it to XML.
  3. The Output box fills with the XML declaration followed by a single <root> element containing your converted data.
  4. Copy the output for use in a config file, an API payload, or any XML-based system.
  5. Click Clear to reset both fields and start over with new data.

Worked Example

Given this JSON, with a nested object under user and an array under tags:

{
  "user": { "name": "Ada" },
  "tags": ["a", "b"]
}

Running it through the converter produces (shown formatted for readability; the actual output is a single line after the declaration):

<?xml version="1.0" encoding="UTF-8"?>
<root><user><name>Ada</name></user><tags>a</tags><tags>b</tags></root>

Notice two things: the user object becomes a nested <user> element wrapping <name>Ada</name>, and the tags array does not produce <item> elements — because it's nested inside the object under the key tags, each entry is repeated as its own <tags> element instead. The generic <item> wrapper is only used when the array sits at the top level of the input, for example converting ["a", "b"] directly would produce <root><item>a</item><item>b</item></root>.

Common Use Cases

Limitations

FAQ

Does it support XML attributes?

No. The converter only produces elements, never attributes. Every JSON key becomes a child element and every value becomes that element's text content or nested children. If you need attributes, you'll need a custom mapping step after conversion.

What happens to arrays?

It depends on where the array sits. Nested inside an object, each item repeats as an element using that key's name (e.g. <tags>a</tags><tags>b</tags>). If the whole input is a top-level array, each entry becomes a generic <item> element instead, since there's no key name to reuse at the root.

Are special characters like & and < escaped?

Yes. Ampersands, angle brackets, double quotes, and single quotes in text values are escaped to their XML entity equivalents so the output remains well-formed even if your strings contain markup-like text.

Is the output wrapped in a root element?

Yes. Every conversion is wrapped in a single <root> element, preceded by the <?xml version="1.0" encoding="UTF-8"?> declaration, so the result is always one valid document with a single top-level node.

Is my data uploaded anywhere?

No. The conversion happens entirely client-side in your browser. Nothing you paste in is sent to a server.

Related Tools & Guides