XML to JSON Converter

Paste XML — a SOAP response, an RSS feed, a config file — and get JSON with predictable rules for attributes and repeated tags.

runs in your browserno uploadno sign-up

Paste XML or load the sample.

JSON output

Output appears here as you type.

The mapping rules

XML and JSON model data differently, so every converter has to pick conventions. Here: each element becomes a key; attributes become keys with a prefix (@ by default, so id="bk101" becomes "@id": "bk101"); an element that appears more than once under the same parent becomes an array; an element with only text becomes a plain value; and text mixed with attributes or child elements goes under "#text". An empty element becomes null.

With "Detect numbers & booleans" on, text such as 44.95, 3 and true becomes a JSON number or boolean; off, everything stays a string, exactly as XML stores it. Values with leading zeros (like postcodes 02134) are always kept as strings.

The one-item array problem

XML has no notion of a list, so a <tag> that appears once becomes a single value, while two <tag>s become an array. If your code expects an array, normalise it after converting (for example Array.isArray(x) ? x : [x]) or use a JSON Schema to catch the difference.

Frequently asked questions

How are XML attributes converted?

As keys with a prefix, @ by default ("@id"). You can change the prefix (for example to _ or -) or set it empty to merge attributes with child elements.

Are namespaces supported?

Element and attribute names keep their prefix as written, such as "soap:Envelope" or "@xmlns:soap", so no information is lost.

What about CDATA sections?

CDATA content is treated as text and placed in the value or "#text", unescaped.

Why do I get a parse error?

The browser’s XML parser is strict: every tag must close, attribute values need quotes, and & must be written &amp;. HTML is not XML — unclosed <br> or <img> tags will fail.

Is my XML uploaded?

No. It is parsed with your browser’s built-in DOMParser; nothing leaves your device.