XML to JSON Converter
Convert XML data to JSON. Turn legacy XML API responses, SOAP payloads, or RSS/Atom feeds into JSON — attributes go under @attributes, text under #text, repeated elements become arrays — right in your browser.
Converting XML into JSON
There are times when you want to see the contents of a legacy XML API, a SOAP exchange or an RSS or Atom feed in the JSON shape you are used to working with. This tool converts the XML you paste in and finishes the whole job inside the browser, so nothing you paste is ever sent anywhere.
**A set of conventions is needed precisely because XML and JSON hold data in fundamentally different ways.** XML distinguishes attributes from text and allows an element of the same name to appear any number of times; JSON has neither of these. Attributes are therefore placed under `@attributes`, the string an element holds directly under `#text`, and repeated elements become arrays. **What cannot be escaped is the ambiguity that arises when a repeatable element happens to occur only once.** In the original XML it is still one instance of something repeatable, but in JSON it looks like a single value, so code on the receiving end is safest when written to handle both one element and many.
How to use it
- Paste the XML A SOAP response or an RSS feed can go in exactly as it stands.
- Review the conversion **Attributes settle under the key `@attributes` and text under `#text`.**
- Compare the structures Set against the original XML, you can confirm which element ended up under which key.
- Copy or download the result Paste it straight into your code, or save it as a file.
Tips for getting more out of it
- Elements with attributes are grouped into an `@attributes` object, kept separate from the element's own text or child elements.
- When an element mixes attributes with child elements or text, the text portion is stored under `#text` so it's never confused with an attribute value.
- Sibling elements sharing the same name are automatically collected into an array — three `
- ` tags become a 3-element array, while a single one stays a plain object.
- An empty element with no attributes, text, or children (e.g. `
`) converts to `null`. - Namespace prefixes like `xmlns` are not split apart — an element stays keyed as `ns:tag`, prefix and all.
Where it comes in useful
Wiring an XML API into JSON-only code
When the receiving side handles nothing but JSON, you can establish the converted shape in advance.
Parsing an RSS or Atom feed
Turning feed entries into JSON makes them far easier to run through a script as they are.
Reading the contents of a SOAP response
**SOAP, hard to read for its nesting and namespaces, becomes much easier to follow once the hierarchy is laid out as JSON.**
Building fixtures for tests
You can derive a JSON mock from a real XML response.
Terms of the conversion convention
- @attributes
- **The key that holds an XML element's attributes.** Since JSON has no notion of an attribute, they are given a key of their own.
- #text
- The key holding the string an element carries directly. It becomes necessary for an element that has both attributes and child elements.
- Repeated element
- An element appearing more than once under the same name. **It becomes an array in JSON, but a lone occurrence appears as a single value rather than an array of one.**
- Namespace prefix
- The `soap:` part of `soap:Body`. In JSON it survives intact as part of the key name.
- Mixed content
- Text and child elements sitting together inside one element. **JSON has no matching structure, which makes this the place where information is most easily lost in conversion.**
- Root element
- The single element at the top of the XML. It becomes the outermost key in the JSON.
Frequently asked questions
Side Note — Why there's no single "correct" way to turn XML into JSON
Unlike the simple row-to-object mapping between CSV and JSON, there's no single universally agreed-upon convention for converting between XML and JSON. XML lets attributes, text nodes, and child elements coexist within one element, while JSON only has plain key-value pairs — so some convention has to be chosen at conversion time. Major implementations like xml2json, xml-js, and org.json have each settled on different rules for how to represent attributes and how to handle text that coexists with child elements.
Even so, developers still run into XML plenty. SOAP-based web APIs, decades-old system integrations in finance, government, and healthcare, RSS/Atom feeds, and Android layout files are just a few of the areas where XML remains the standard format today. There's a persistent need to take data pulled from these legacy systems and feed it into a modern, JSON-only toolchain — processing it with jq, or manipulating it as a plain object in JavaScript.
The `@attributes`/`#text` convention this tool uses is a common, practical choice rather than a fully symbol-heavy notation. Leaf elements with no attributes convert straight to their text value, which keeps simple config values or an RSS title readable as plain JSON, while elements that do carry attributes are explicitly separated out — so glancing at the converted result tells you exactly which values were originally attributes.