Data & AnalyticsLive🔒 Private

XML to JSON

Convert XML to JSON instantly. Free online XML to JSON converter — handles attributes and nested elements. No signup, 100% private, browser-based.

How it works

The XML to JSON converter transforms XML documents into equivalent JSON — parsing the element hierarchy, attributes, text nodes, and CDATA sections into a clean JSON object structure. Use it to adapt XML API responses for JavaScript consumption, migrate XML configuration files to JSON, or modernize XML-based data pipelines.

XML and JSON represent the same hierarchical data structures differently. REST APIs use JSON; SOAP and legacy enterprise APIs use XML. RSS and Atom feeds are XML; most modern feed parsers expect JSON. Converting between the two is a constant interoperability task.

How to use it: paste XML source into the input field or upload an .xml file. The converter produces JSON and shows it in a formatted preview. Configure the conversion options: attribute handling (attributes as @attribute keys, or merged with child elements), text node handling (text key name for text mixed with child elements), array inference (elements that appear multiple times are auto-converted to JSON arrays).

Attribute handling options: - Ignore attributes: only element content is converted - @prefix: {"element":{"@attr":"value","#text":"content"}} - Merge: attributes are treated as additional child properties

Array inference: if an XML element appears more than once at the same level (e.g., multiple <item> elements), it is automatically converted to a JSON array rather than overwriting the previous value.

Privacy: XML parsing runs in the browser.

Frequently Asked Questions

How does the tool handle XML attributes?
By default, attributes are included as @attribute-name keys: <item id='1'> → {"item":{"@id":"1"}}. Toggle 'Merge attributes' to treat attributes as peer properties of the element: {"item":{"id":"1"}}. Toggle 'Ignore attributes' to discard all attribute data.
What happens if my XML has multiple elements with the same name?
Same-named sibling elements are automatically converted to a JSON array: <items><item>A</item><item>B</item></items> → {"items":{"item":["A","B"]}}. If only one element with that name exists, it's kept as a single value — not an array. Toggle 'Always use arrays' to force array wrapping for all elements.
Does it handle XML namespaces?
Namespace prefixes are preserved as part of the key name: <ns:element> → {"ns:element": ...}. Namespace URI declarations (xmlns:ns='...') are included as @xmlns:ns properties. For clean output without namespace prefixes, enable 'Strip namespaces'.
What is CDATA and how is it handled?
CDATA sections (<![CDATA[...]]>) contain character data that should not be parsed as XML markup. CDATA content is treated as plain text string values in the JSON output — the CDATA wrapper is removed and the inner text is returned as the property value.