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.

Usage tips

  • 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.

Frequently asked questions

Each element's attributes are grouped into an `@attributes` key holding an object. For example, `` becomes `{"@attributes": {"category": "fiction"}, ...}`, kept separate from the element's own value (its text or children) so the two are never confused.

When sibling elements under the same parent share a name, they're automatically collected into an array. For example, two `` tags produce a `book` key whose value is a 2-element array; a single `` stays a plain object instead.

The most common cause is a missing or mismatched closing tag (closing with a different name than the one that was opened). XML also requires exactly one root element, so pasting multiple top-level elements like `......` will also fail.

This tool only supports the XML-to-JSON direction. If you need to format or validate JSON or XML on their own, check the other formatter tools on this site.

Namespace prefixes are kept as-is rather than being separated out, so an element stays keyed as `ns:tag`. Namespace resolution — mapping a prefix to its URI — isn't performed, so XML with complex namespaces may not convert into the structure you'd expect.
ツールくん

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.