August 13, 2026

How JSON Arrays Become Repeated XML Elements

A JSON array doesn't have a direct XML equivalent, so converters represent it the same way XML has always represented repetition: as multiple sibling elements sharing the same tag name. "tags": ["a", "b", "c"] becomes <tags>a</tags><tags>b</tags><tags>c</tags> — three separate elements, not one element containing a list.

JSON to XML converter showing a JSON object converted into nested XML elements with a root wrapper

Why this loses information JSON originally had

JSON's array type explicitly marks something as "a list, even if it has one item." Once converted to repeated XML elements, that distinction disappears — a document with exactly one <tags> element looks structurally identical whether the original JSON had a single-item array or a plain string field. Converting that XML back to JSON later requires the receiving system to already know which elements are supposed to be treated as arrays.

Arrays of objects work the same way, one level deeper

"items": [{ "id": 1 }, { "id": 2 }] becomes two sibling <items> elements, each containing its own nested <id> child — the repetition rule applies uniformly whether the array holds primitive values or full objects.

The practical fix on the receiving end

If you're building the system that will read this XML back, decide up front which element names should always be treated as arrays (even when only one appears in a given document) and enforce that consistently — this is exactly the fix described in this site's XML-to-JSON conversion guide, and it's the same underlying ambiguity showing up from the other direction.

Want to try this yourself?

Open JSON to XML