JSON Formatter Pro

Converter

XML to JSON Converter Pro

Convert SOAP responses, RSS feeds, and legacy config XML into clean JSON — with attribute, text node, and repeated element mapping documented in full.

Nothing you paste leaves your browser

What is XML to JSON conversion?

XML to JSON conversion parses an XML document and rewrites its elements, attributes, and text as JSON. Each XML element becomes a JSON key, nested elements become nested objects, an element that repeats becomes an array, element attributes are preserved with an @ prefix on their names, and the text inside an element becomes its value. This lets data locked in XML — a W3C standard since 1998, still used by SOAP web services, RSS and Atom feeds, sitemaps, and legacy enterprise systems — be consumed by modern JSON APIs and JavaScript code. JSON Formatter Pro converts XML to JSON entirely in your browser using the browser’s own XML parser, so nothing you paste is uploaded to a server; this matters when the document carries account or transaction data. It is the exact inverse of the JSON to XML tool. Paste XML or upload a file and get structured JSON to copy or download.

Worked example: XML → JSON

XML to JSON conversion example Example: XML input on the left is converted to JSON output on the right. XML <note id="1" lang="en"> <to>Tove</to> <body>Hi</body></note> convert JSON { "note": { "@id": "1", "@lang": "en", "to": "Tove", "body": "Hi" }}
Elements become keys, attributes are prefixed with @, and text content is inlined — the inverse of JSON to XML.

How XML maps to JSON

XML JSON
element key
nested elements nested object
repeated element array
attribute "@name" key
element text the value

Complete Guide to Converting XML to JSON Online

XML did not go away — it retreated into the systems that are hardest to replace. SOAP web services, RSS and Atom feeds, Android manifests and layout resources, Maven POMs, Spring and log4j configuration, ISO 20022 and XBRL financial messages, and a large share of government open-data feeds all still arrive as XML. The clients consuming them — React front ends, mobile apps, serverless functions, analytics warehouses — all expect JSON. Converting XML to JSON is the seam between those two worlds, and it is usually where an integration project actually begins.

XML to JSON Converter Pro parses your document with the browser's own XML parser and emits JSON using a mapping that is written out in full on this page. Paste a SOAP envelope, an RSS channel, an `AndroidManifest.xml`, or a regulatory data feed and read the JSON immediately, with no upload and no signup.

How to Convert XML to JSON Online

  1. Paste or Upload XML: Paste your document into the left editor, or drop an `.xml` file onto it. The status bar reports Valid XML, or Invalid XML with the parser's own reason for rejecting it.
  2. Read the JSON: The output panel re-converts as you type and renders the result as syntax-highlighted JSON.
  3. Pick Your Indentation: The toolbar's indent control (2, 3, or 4 spaces, or tabs) applies to the emitted JSON.
  4. Copy or Download: Click Copy for the clipboard, or Download to save the result as `converted.json`.

How This Converter Maps XML to JSON

XML and JSON are not isomorphic, so every XML-to-JSON tool has to invent a convention — and the conventions differ between tools. These are the exact rules this converter applies:

XML construct JSON result Example
Root element Single top-level key wrapping the document `<catalog>…` → `{ "catalog": … }`
Attribute Key prefixed with `@`, value always a string `id="bk101"` → `"@id": "bk101"`
Text-only element Plain JSON string (trimmed) `<title>Refactoring</title>` → `"title": "Refactoring"`
Text plus attributes or children Text moves under a `#text` key `<price currency="USD">39.95</price>` → `{ "@currency": "USD", "#text": "39.95" }`
Empty element, no attributes `null` `<notes/>` → `"notes": null`
Repeated sibling tags Array under that tag name two `<book>` → `"book": [ … , … ]`
Namespace prefix Kept verbatim in the key `<soap:Body>` → `"soap:Body"`, `"@xmlns:soap"`
Comment, processing instruction, CDATA Comments and PIs dropped; CDATA read as text `<![CDATA[<b>hi</b>]]>` → `"<b>hi</b>"`

When an XML document is converted to JSON, the converter has to settle four things the two formats disagree about. XML attributes have no JSON equivalent, so each attribute becomes a key prefixed with `@`: `<book id="bk101">` yields `"@id": "bk101"`. XML has no array type, so repeated sibling elements sharing a tag name collapse into a JSON array, while a tag appearing once stays a single object. XML text can sit alongside attributes and child elements, so an element carrying both puts its text under a `#text` key, while an element holding nothing but text becomes a plain JSON string. Finally, XML is untyped: `<year>1999</year>` is character data, not a number, so every value arrives in JSON as a string. Learn those four rules and you can predict the exact output for any well-formed document, without trial and error.

Worked Example: An Attribute, Repeated Siblings, and an Empty Tag

Input XML:

<?xml version="1.0" encoding="UTF-8"?>
<catalog updated="2026-04-18">
  <book id="bk101" available="true">
    <title>The Pragmatic Programmer</title>
    <price currency="USD">39.95</price>
  </book>
  <book id="bk102" available="false">
    <title>Refactoring</title>
    <price currency="USD">54.99</price>
  </book>
  <notes/>
</catalog>

Produced JSON:

{
  "catalog": {
    "@updated": "2026-04-18",
    "book": [
      {
        "@id": "bk101",
        "@available": "true",
        "title": "The Pragmatic Programmer",
        "price": {
          "@currency": "USD",
          "#text": "39.95"
        }
      },
      {
        "@id": "bk102",
        "@available": "false",
        "title": "Refactoring",
        "price": {
          "@currency": "USD",
          "#text": "54.99"
        }
      }
    ],
    "notes": null
  }
}

Five conventions are visible at once here. The root tag became the single top-level key. The `updated` attribute became `@updated`. The two `<book>` siblings became an array, while `<title>` — which appears once inside each book — stayed a plain string. `<price>` carried both an attribute and text, so its text moved to `#text`. The self-closing `<notes/>` became `null`, and the XML declaration was dropped as a processing instruction.

Key Technical Capabilities

🏷️ Attributes Preserved, Not Discarded

Every attribute survives the conversion as an `@`-prefixed key, so `id`, `currency`, `xmlns`, and SOAP metadata are never silently dropped.

🔁 Repeated Elements Become Arrays

RSS `<item>` lists, Atom `<entry>` lists, and repeated record tags collapse into real JSON arrays your client can map over.

🧭 Namespace-Aware Keys

Prefixes stay verbatim (`soap:Envelope`, `@xmlns:xsi`), so namespaced enterprise payloads keep the structure their schema describes.

🔒 Parsed Entirely in Your Browser

Your browser's built-in XML parser does the work in-page — no upload, no account, no file-size tier, no ads.

The Mapping Rules Are Documented, Not Guesswork

The single most important thing to know about an XML-to-JSON converter is its convention, because there is no standard one. Does an attribute become `@id`, `_id`, or a nested `attributes` object? Does a lone `<item>` come back as an array or an object? Does `<count>7</count>` become `7` or `"7"`? Many free online converters simply show you a result and let you reverse-engineer the answers from whatever sample you happened to paste — which is how integrations end up with a bug that only appears once a feed drops from two items to one. The table and worked example above exist so you never have to guess, and the exact conversion source is public.

The privacy story is equally concrete. XML shows up in the highest-stakes corners of an enterprise — payment messages, patient records, internal SOAP contracts, signed configuration — and those are exactly the documents you should not be posting to an unknown backend just to reshape them. Here the document is parsed by your own browser inside the page — the same parse your browser performs on any XML resource — so it never crosses the network to be converted, and the wider app's JSON work (formatting, validation, statistics) is offloaded to a Web Worker rather than a backend. Rather than asking you to trust that, the whole project is open source — read the converter yourself in the GitHub repository, or self-host it.

Two honest limitations are worth repeating, because a converter that hides them is worse than one that states them. First, values are never type-inferred: everything is a string, which is safe for account numbers and identifiers but means you cast on your side. Second, single-occurrence elements are objects rather than one-element arrays — a consequence of XML's own ambiguity, not a bug you can configure away, so defensive code should normalize before iterating.

What to Do With the JSON Next

Once the feed is JSON, the rest of the toolchain opens up. Feed a converted payload into the JSON to TypeScript generator to get interfaces for the client that consumes it, or into the JSON Schema generator to write a contract test against the feed's shape before it changes under you. If you need to inspect or reformat a large converted document, the JSON formatter and tree viewer handles it. And when you have to send data back the other way — replying to a SOAP endpoint or regenerating a config file — the JSON to XML converter is the inverse direction of this page.

Legacy integrations rarely arrive in one format, either. The same input pane also accepts other sources: use the YAML to JSON converter for pipeline and Kubernetes configuration, or the CSV to JSON converter for the flat exports that so often accompany an XML feed.

Frequently Asked Questions (FAQ)

How are XML attributes represented in the JSON output?

Every attribute becomes a key on the element's object, prefixed with `@`. So `<book id="bk101" available="true">` produces `"@id": "bk101"` and `"@available": "true"` alongside the element's child keys. The prefix exists because XML lets an attribute and a child element share the same name — `@` keeps them from colliding. Attribute values are always strings, exactly as XML defines them.

How are repeated sibling elements converted into JSON arrays?

When two or more child elements of the same parent share a tag name, they collapse into a single JSON array under that tag. Two `<book>` siblings become `"book": [ { … }, { … } ]`. Important caveat: a tag that appears only once stays a single object, not a one-element array, because XML itself gives no way to tell "a list that happens to have one item" from "a single item". If you consume the output programmatically, normalize with something like `[].concat(node.book ?? [])`.

Are numbers and booleans in XML converted to JSON numbers and booleans?

No — deliberately. XML text is character data with no type information, so `<year>1999</year>` becomes the string `"1999"` and `available="true"` becomes the string `"true"`. Guessing types would silently corrupt real data: leading-zero account numbers, phone numbers, ISO 20022 amounts, and long identifiers all lose meaning the moment they are coerced to numbers. Cast explicitly on your side, where you know the schema.

Can I convert a SOAP envelope or an RSS feed to JSON?

Yes. Both are ordinary XML documents. Namespace prefixes are preserved verbatim, so a SOAP response keeps keys like `soap:Envelope`, `soap:Body`, and `@xmlns:soap`, and you can walk straight to the payload element inside the body. For RSS or Atom, the repeated `<item>` or `<entry>` elements become a JSON array, which is usually the exact shape a front end wants.

What happens to comments, CDATA sections, and mixed content?

Comments, processing instructions (including the `<?xml … ?>` declaration), and whitespace-only text nodes are dropped. CDATA is read as ordinary text. If an element carries text alongside attributes or child elements, that text is stored under a `#text` key. One structural limit worth knowing: if the same tag repeats non-adjacently among differently-named siblings, the repeats merge into one array, which loses their original interleaved order — an unavoidable trade-off for object-shaped output.

Is my XML uploaded to a server?

No. The document is parsed by your own browser's built-in XML parser inside the page, and the JSON is produced there too. Nothing is transmitted, logged, or stored server-side, there is no account to create, and the project is open source so you can verify the conversion code yourself.