XML to JSON Converter

Paste XML and get JSON instantly — attributes, nested elements and repeated tags are all handled. Flip the toggle to convert JSON back to XML. Runs in your browser, nothing uploaded.

XML input
JSON output

What does this tool do?

This free XML to JSON converter turns an XML document into clean JSON as you type, and converts JSON back to XML with the reverse toggle. It runs entirely in your browser — nothing you paste is uploaded — so it is safe for config files and API payloads, and it works offline once loaded. If your source is YAML rather than XML, the home page converts YAML to JSON the same in-browser way.

How XML maps to JSON

XML and JSON do not have a one-to-one structure, so this tool uses the widely-adopted convention:

The reverse direction (JSON to XML) reads the same convention back: @ keys become attributes, #text becomes element text, and arrays become repeated tags.

Real-world examples

The most common reason to convert XML to JSON is to pull a legacy payload — a SOAP response, an RSS feed, or an old config file — into a modern app that expects JSON. For example, this RSS item:

<item>
  <title>Release 2.0</title>
  <link>https://example.com/2.0</link>
  <category domain="release">major</category>
</item>

becomes JSON your JavaScript can read directly:

{
  "item": {
    "title": "Release 2.0",
    "link": "https://example.com/2.0",
    "category": { "@domain": "release", "#text": "major" }
  }
}

Both conventions are visible here: the domain attribute became @domain, and because <category> has an attribute and text, the text moved into #text. The same pattern handles SOAP envelopes, Atom feeds, sitemaps, and office-format XML.

Convert XML to JSON in code (Python, JavaScript, CLI)

This page is the zero-install option; inside a script the libraries are short:

How to use it

XML vs JSON

XML is verbose and document-oriented, with attributes, namespaces and a rich schema ecosystem — still common in enterprise systems, SOAP APIs, RSS/Atom feeds, and office file formats. JSON is lighter and maps directly onto the data structures of modern programming languages, which is why most web APIs moved to it. Converting XML to JSON is a frequent step when modernizing an integration or pulling a legacy feed into a JavaScript app.

Common uses

FAQ

How are XML attributes represented in JSON?

Each attribute becomes a key prefixed with @. For example <user id="7"> becomes { "user": { "@id": "7" } }.

What happens to repeated tags?

Repeated sibling elements with the same name are collected into a JSON array automatically.

Does it handle XML namespaces?

Yes. A namespaced tag like <ns:item> keeps the prefix in the JSON key ("ns:item"), so nothing is lost.

What about CDATA sections?

The text inside a <![CDATA[ … ]]> block is treated as the element's text content, exactly like ordinary text.

Does it work offline?

Yes. Once the page has loaded it runs without a network connection — the XML parser is your browser's own.

Can I convert JSON back to XML?

Yes. Switch the toggle to JSON → XML; @ keys become attributes, #text becomes element text, and arrays become repeated tags.

Is my data uploaded?

No. Conversion runs entirely in your browser; nothing you paste leaves your device.

Why do I get a parse error?

XML must be well-formed: every tag closed, one root element, and attribute values quoted. The error message points to the problem.

More format converters