Data Format Converters

XML to JSON Converter

Paste XML — an RSS feed, a SOAP response, a sitemap, a config file — and get JSON back. Attributes are preserved rather than discarded, and repeated sibling elements become arrays so the result is actually usable in code.

  • Free, no sign-up
  • Runs in your browser
  • Nothing uploaded
  • Updated Sep 2026
Input
XML input
JSON output
Waiting for input

At a glance

Direction
XML → JSON
Processing
Entirely client-side using the browser's own XML parser
Attributes
Preserved with an @ prefix by default
Repeated elements
Collapsed into JSON arrays
Handles
RSS, Atom, SOAP, sitemaps, SVG, plain XML
Cost
Free, no account, no rate limit

What this converter does

XML and JSON do not map onto each other cleanly, and any converter has to make choices. XML has attributes, JSON does not. XML distinguishes an element that appears once from one that appears twice; JSON needs to know in advance whether something is an array. XML allows text and child elements side by side in the same node; JSON has no equivalent.

The conventions used here are the ones most widely adopted, so the output matches what libraries like xml2js produce and what most code expects. Attributes get an @ prefix, so <item id="4"> becomes {"@id": 4}. When an element has both attributes and text, the text lands under #text. Repeated siblings with the same name collapse into an array. An element with only text and no attributes becomes that text directly, with no wrapper object, which keeps the output far less noisy than a naive conversion.

Parsing uses the browser's own XML engine, so it is strict in the same way a real consumer would be — an unclosed tag or an undeclared entity produces an error rather than guesswork.

The single-element array problem

This is the one thing that catches people out, and it is worth understanding because it is a property of XML rather than a flaw in any particular tool.

When a feed contains three <item> elements, they collapse into an array of three. When the same feed contains one, there is nothing to signal that it is a collection, so it becomes a single object. Code written against the three-item version then breaks on the one-item version — usually in production, usually at the worst moment.

The defence is on the consuming side, not the converting side. Normalise before you iterate: const items = [].concat(data.rss.channel.item || []) gives you an array in both cases. Some converters offer a "force array" list of element names, which solves it at conversion time, but you still need the defensive line if the JSON might come from anywhere else.

What XML features do not survive

Several XML constructs have no JSON representation and are dropped:

  • Namespaces are kept as literal prefixes in the key name (dc:creator stays dc:creator) but the namespace declaration itself is just another attribute. JSON has no namespace concept.
  • Comments and processing instructions are discarded entirely.
  • Element order between differently-named siblings is preserved only by JavaScript's object key ordering, which you should not rely on.
  • Mixed content — text interleaved with elements, as in <p>Hello <b>there</b>!</p> — loses the position of the text relative to the children. For document-oriented XML like XHTML, converting to JSON is usually the wrong approach; keep it as XML and use a DOM parser.
  • DTDs and schemas are ignored. The conversion checks well-formedness, not validity.

For data-oriented XML — feeds, API responses, configuration — none of these matter much. For document-oriented XML, they matter a great deal.

How to use the XML to JSON Converter

  1. Paste or upload your XML

    Any well-formed XML works: RSS, Atom, SOAP envelopes, sitemaps, SVG or a plain config file.

  2. Choose how attributes are marked

    The @ prefix is the common convention and keeps attributes distinguishable from child elements. You can switch to an underscore or remove the prefix entirely.

  3. Decide on type inference

    With inference on, <count>42</count> becomes the number 42. Turn it off to keep every value as a string.

  4. Copy or download the JSON

    Take the result into your code, or save it as a .json file.

Frequently asked questions

Is my XML sent anywhere?

No. Parsing uses the browser's built-in DOMParser inside the page. Nothing leaves your machine, which matters for SOAP responses that often carry authentication headers or customer records.

How are attributes handled?

They are kept, prefixed with @ by default, so <book isbn="123"> becomes {"@isbn": 123}. Many converters simply discard attributes, which quietly loses data — often the identifiers you most need.

Why did a list become a single object?

Because the XML contained only one of that element, and nothing in XML marks it as a collection. Guard against it in your code with [].concat(value || []), which yields an array whether the source had one item or many.

Can I convert an RSS feed with this?

Yes — RSS and Atom are ordinary XML. Paste the feed source and the items become an array under rss.channel.item. You will need to fetch the feed yourself first, since the browser's same-origin policy stops this page from fetching it for you.

What does a parse error mean?

The XML is not well-formed — most often an unclosed tag, a stray & that should be &amp;, or mismatched nesting. The message from the browser's parser usually points at the location. XML is unforgiving here by design.

Can I convert JSON back to XML?

The reverse mapping is supported by the same conventions — @ keys become attributes and #text becomes text content — but a JSON document that was not produced by this converter will rarely map onto meaningful XML without some manual shaping.