Convert JSON Array to XML — How Arrays Become Repeated Elements
- A JSON array becomes a set of repeated sibling elements in XML, each sharing the array key's tag name.
- Arrays of objects nest each object inside its own element; nested arrays stack repeating elements.
- One gotcha: XML doesn't distinguish a single-item array from a single value — your consumer has to know the shape.
Table of Contents
A JSON array becomes repeated sibling elements in XML, each using the array's key name. So "tags": ["a","b","c"] becomes three <tags> siblings. This guide covers every array shape you'll encounter — flat arrays, arrays of objects, nested arrays, mixed-type arrays, and empty arrays — plus the one rule every XML consumer has to know up front.
Flat Arrays of Primitives
Simplest case. Input:
{"tags": ["admin", "beta", "vip"]}
Output:
<root> <tags>admin</tags> <tags>beta</tags> <tags>vip</tags> </root>
Each value gets its own element. The parent doesn't exist in XML — in JSON the array is the value of tags; in XML there's no "array" concept, just repeated siblings.
This is why XML consumers must know which elements repeat. The converter can't declare a schema for you, so if your downstream parser expects a <tagList> wrapper, you'll need to restructure the JSON before converting.
Arrays of Objects
Each object becomes a container element with the array key as its tag name. Input:
{"users":[
{"name":"Ana","role":"admin"},
{"name":"Ben","role":"viewer"}
]}
Output:
<root>
<users>
<name>Ana</name>
<role>admin</role>
</users>
<users>
<name>Ben</name>
<role>viewer</role>
</users>
</root>
This is the most common shape — a collection of records. Works cleanly with XSLT, DOM parsers, and most SOAP services.
Sell Custom Apparel — We Handle Printing & Free ShippingNested Arrays and Mixed Types
Nested arrays get flattened into the parent's repeating element. Input:
{"groups":[["a","b"],["c","d"]]}
Output repeats <groups> four times because the outer array's two items (each an array of two) each flatten into two siblings. If you need preserved grouping, change the JSON structure to objects first:
{"groups":[
{"items":["a","b"]},
{"items":["c","d"]}
]}
Mixed-type arrays work but produce inconsistent-shaped siblings. Avoid them if your XML consumer validates against a schema — XSD generally expects all repeating elements to have the same structure.
Empty Arrays and Single-Item Arrays
An empty array produces no output for that key. {"tags":[]} results in zero <tags> elements — nothing tells the consumer "there is a tags field, it's just empty." If your XML schema requires a placeholder, handle it before conversion.
A single-item array looks identical to a single scalar in XML: {"tags":["only"]} and {"tags":"only"} both produce <tags>only</tags>. This is the fundamental JSON-to-XML ambiguity. The consumer must know from a schema or convention whether to always expect repetition.
When the Tool Is Enough and When to Write Code
For pasting one JSON blob and getting valid XML out, the browser converter is enough. If you're doing this inside a service that processes thousands of payloads with configurable schema rules, you want a real library — Jackson's XmlMapper in Java, xml2js in Node, or Python's dicttoxml. Each of those gives you explicit control over wrappers, attribute promotion, and schema validation that a paste-and-click tool can't.
Related: our SOAP-specific guide covers wrapping this output in an envelope, and the attributes guide covers the one-off attribute workaround.
Convert Your JSON Arrays to XML
Paste the JSON, click Convert, and see exactly how your array shape maps to repeated elements.
Open Free JSON to XML ConverterFrequently Asked Questions
Why do repeated elements not have a wrapper like ?
XML doesn't have an array concept. A "list of tags" is just repeated
How does the converter handle a single-item array?
Single-item arrays look identical to a scalar value in XML. Both produce one element. This is a fundamental JSON-to-XML limitation — there's no way to preserve the "it's an array" signal once you're in XML without extra wrapping.
Can I produce nested arrays like - ?
Not directly — you'll need to restructure the JSON. Change each inner array to an object: [{"items":["a","b"]}]. Then the outer array repeats
What about arrays of mixed types?
The converter handles them — each item becomes a sibling of the appropriate shape. But downstream XSD validators usually reject mixed-type siblings, so avoid mixed arrays if your consumer validates.

