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 (&, <, >, ", ') 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
- Paste any valid JSON — an object, an array, or a plain value — into the Input box on this page.
- Click Run to convert it to XML.
- The Output box fills with the XML declaration followed by a single
<root>element containing your converted data. - Copy the output for use in a config file, an API payload, or any XML-based system.
- 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
- Integrating with legacy systems — many older enterprise systems and SOAP-based APIs still require XML payloads rather than JSON.
- Generating XML config or data files — quickly turn a JSON object into an XML file for tools that only read XML configuration.
- Feeding XML-based pipelines — convert a modern JSON API response into XML for downstream systems, ETL jobs, or XSLT processing that expect XML input.
- Prototyping XML structures — sketch out data in JSON (faster to hand-write) and instantly see the equivalent XML shape.
- Testing XML parsers — generate quick, valid XML samples from JSON fixtures for unit tests.
Limitations
- No XML attributes. Everything becomes a child element or text content — there is no way to produce output like
<user id="1">withidas an attribute. If your target system requires attributes, you'll need a custom mapping step after conversion. - Array items get a generic name, not a semantic one. A top-level array's entries all become
<item>elements regardless of what the data represents — there's no way to tell the tool to call them<product>or<order>instead. - No schema or DTD awareness. The converter has no concept of a target XML schema, namespaces, or element ordering rules some XML consumers expect — it produces a straightforward structural mirror of your JSON.
- Always wrapped in
<root>. You cannot currently choose a different name for the top-level wrapping element.
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
- Browse all JSON tools
- JSON Formatter & Prettifier — clean up and validate your JSON before converting it.
- Read more JSON guides on the blog