Illustration of XML attributes and repeated sibling elements mapping to @attributes and JSON arrays

File & Data

How XML Elements, Attributes, and Arrays Map to JSON

The XML to JSON mapper uses stable conventions so the same document always produces the same JSON shape.

Ready to try the tool this guide describes?

@attributes

Every XML attribute is copied into an @attributes object with string values.

#text

When an element has attributes or child elements and also has text, the text is stored under #text.

Repeated siblings

Two or more sibling elements with the same name become a JSON array. A single sibling stays a normal value.

Namespaces

Element keys use the DOM nodeName, which preserves prefixes such as ns:tag. xmlns declarations appear under @attributes when present.

XML Elements Attributes Arrays to JSON FAQ

Are numbers inferred?
No. Element text stays a JSON string, so 0 and false remain text.
What about empty elements?
An empty element with no attributes becomes an empty string.
Is processing private?
Yes. Conversion runs locally in your browser and files are not uploaded to Looty Tools servers for this workflow.
What file size limit applies?
Inputs must be 25 MB or smaller unless a tool-specific limit says otherwise.
Can I copy the result?
Yes. After a successful conversion you can copy the output text or download the file.

Related guides

Open the tool

Jump into XML to JSON when you are ready to process your files.

← Back to all guides