Developer
Encoders, converters & dev utilities
XML to JSON Converter
Convert XML into JSON with a clear, documented mapping so you know exactly what you get. Elements become object keys, and when a tag repeats inside its parent it collapses into a JSON array — so <r><item>1</item><item>2</item></r> becomes {"r":{"item":["1","2"]}}. Attributes are surfaced as keys with an @_ prefix (the fast-xml-parser convention), e.g. <a x="1"/> becomes {"a":{"@_x":"1"}}, which keeps them distinct from child elements. Text and attribute values are kept as raw strings so numeric-looking text is not silently coerced. XML is parsed per the W3C XML 1.0 spec; JSON is emitted per RFC 8259. Runs 100% in your browser — nothing is uploaded. Free, no login.
Elements → object keys; a repeated child tag collapses into a JSON array
- Worked example — <r><item>1</item><item>2</item></r> → {"r":{"item":["1","2"]}}
- Attributes surfaced with an @_ prefix: <a x="1"/> → {"a":{"@_x":"1"}}
- Text/attribute values kept as raw strings (no silent numeric coercion)
- XML parsed per W3C XML 1.0; JSON per RFC 8259 — 100% client-side, nothing uploaded
Frequently asked questions
How does the XML to JSON conversion handle repeated tags?
A tag that appears more than once inside the same parent is collapsed into a JSON array, preserving order. So <r><item>1</item><item>2</item></r> converts to {"r":{"item":["1","2"]}} rather than losing all but the last item. A tag that appears once stays a single value. This is the standard way to represent XML's ordered, repeatable child elements in JSON, which has no separate "repeatable element" concept.
What happens to XML attributes?
Attributes are surfaced as object keys prefixed with @_ so they never collide with child-element names. For example <user id="1"><name>Ada</name></user> becomes {"user":{"@_id":"1","name":"Ada"}}. The @_ convention (from fast-xml-parser) makes it unambiguous which JSON keys came from attributes versus child nodes, which matters if you later rebuild the XML.
Are numeric-looking values converted to numbers?
No — element text and attribute values are kept as raw strings. So <item>1</item> becomes the string "1", not the number 1. XML is untyped (per the XML 1.0 spec everything is character data), so keeping values as strings avoids silently changing an ID, version, or zero-padded code. If you need JSON numbers you can convert the specific fields yourself after the transform.