AnyFormat

00 XML → JSON

XML to JSON

Attributes preserved, well-formedness checked, position-accurate errors.

01XML in
02JSON out
03Options 6

XML cannot express "a list of one". Always-arrays gives every consumer a consistent shape at the cost of extra brackets.

Attributes are prefixed with @ so they cannot collide with child elements.

Removes the outermost wrapper so the result starts at the useful data.

  • No upload The conversion runs in this tab. Your file never travels — not to us, and not to the advertising.
  • No sign-up, no email, no daily cap There is no account system to sign up to.
  • No size limit we invented Only your device's memory — about ~2 GB on a desktop browser, ~400 MB on a phone.
  • Turn your Wi-Fi off and convert anyway The conversion needs nothing but this page. Ads will not load without a connection; your file will still convert. That is the whole claim, and it takes five seconds to check.

Paste XML or drop a file. The document is checked for well-formedness first, so a malformed file gets a line and column rather than a silent half-conversion. Everything runs in this tab.

The single-element problem

This is the one thing that makes XML-to-JSON genuinely hard, and every converter handles it differently. XML has no way to say "this is a list that happens to have one item in it". <items><item/><item/></items> is obviously a list; <items><item/></items> is indistinguishable from a single value.

By default an element becomes an array only when it actually repeats, which produces the most natural-looking JSON. The cost is that your consuming code has to handle both shapes, and it will eventually receive a one-item response and break.

Set Repeated elements to Always arrays and every element becomes an array without exception. The JSON is uglier and the shape is completely predictable. For anything programmatic, choose this one.

Attributes and text content

Attributes are kept and prefixed with @, so <person id="1">Ada</person> becomes {"@id": 1, "#text": "Ada"}. The prefix exists because an attribute and a child element can share a name and would otherwise collide silently.

An element with only text and no attributes collapses to the bare value rather than an object with a single #text key, which keeps ordinary documents readable. If you do not need attributes at all, turning them off produces markedly cleaner output.

What does not survive the trip

Some things have no JSON equivalent and are dropped: XML namespaces are flattened to their prefixed names, comments and processing instructions are discarded, and CDATA sections become ordinary text. Mixed content — text interleaved with child elements, as in <p>Hello <b>world</b>!</p> — loses the ordering, because JSON objects have no way to interleave a string with a key. Document-shaped XML like XHTML converts poorly for that reason; data-shaped XML converts cleanly.

Other names for this

Also searched as “xml to json converter”, “convert xml file to json”, “rss to json”.

Questions

Why do some keys start with @?
Those are XML attributes. The prefix keeps them from colliding with child elements that happen to share the name. You can turn attributes off entirely in the options.
A field is sometimes an array and sometimes an object.
That is the single-element problem. Set “Repeated elements” to “Always arrays” for a shape that never varies.
What about namespaces?
Prefixes are kept as part of the key name (soap:Body), but the namespace URI declarations are not resolved. JSON has no namespace concept to map them onto.
Can it handle an RSS feed or an SVG?
Yes — both are XML. RSS converts very cleanly. SVG converts correctly but the result is rarely useful, since SVG is document-shaped rather than data-shaped.
Is my data uploaded anywhere?
No. The conversion runs as JavaScript inside this tab. Open your browser's Network panel and convert something — you will see no request carrying your data, because there is no server to send it to. You can also turn your Wi-Fi off and convert anyway.