XML to JSON Converter Online — Free & Fast

Map XML elements, attributes, namespaces, CDATA sections, and mixed content into clean JSON in a single click. 100% in your browser — no upload, no rate limits.

What is an XML to JSON Converter?

An XML to JSON converter walks an XML document tree and emits an equivalent JSON object — turning elements into keys, attributes into @-prefixed properties, repeated children into arrays, and CDATA blocks into plain strings. It bridges legacy SOAP and RSS systems with modern JavaScript front-ends, MongoDB stores, and REST APIs without requiring you to write XSLT or DOM-walking code by hand.

XML is verbose and JSON is compact, but the bigger problem is shape: XML mixes elements, attributes, text nodes, and namespaces freely, while JSON has only objects, arrays, strings, numbers, booleans, and null. The OpenFormatter converter applies the widely-used Microsoft / Badgerfish convention — @ for attributes, #text for mixed content, arrays for repeated tags — so the output is predictable and consumable by any JavaScript code.

How to convert XML to JSON online — 4 steps

  1. Paste your XML. Drop a SOAP response, RSS feed, Maven pom.xml, Spring config, or any well-formed XML into the Input panel. Click Load Sample for a quick demo.
  2. Click Convert. The browser's native DOMParser parses the XML; a recursive walk turns elements into JSON keys with attributes prefixed by @.
  3. Inspect the JSON. Repeated siblings become arrays, namespaces are preserved verbatim (dc:title), and CDATA content is unwrapped to plain strings.
  4. Copy or save. Click Copy to send the JSON to your clipboard. Paste it into a JS file, a REST request body, or a unit-test fixture.

Sample XML and JSON output

A small library document showing attributes, namespaces, CDATA, and repeated child elements — and the JSON it produces.

XML input

<library xmlns:dc="http://purl.org/dc/elements/1.1/">
  <book id="b-001" available="true">
    <dc:title>The Pragmatic
      Programmer</dc:title>
    <author>Andy Hunt</author>
    <author>Dave Thomas</author>
    <year>1999</year>
  </book>
</library>

JSON output

{
  "library": {
    "@xmlns:dc": "http://purl.org/...",
    "book": {
      "@id": "b-001",
      "@available": "true",
      "dc:title": "The Pragmatic Programmer",
      "author": ["Andy Hunt", "Dave Thomas"],
      "year": 1999
    }
  }
}

Attribute Mapping

Every XML attribute becomes a JSON key prefixed with @, so attributes never collide with child element names. Round-trippable with a JSON-to-XML pass.

Namespace-Aware

Namespace prefixes (dc:, soap:, atom:) are kept verbatim in the keys, and xmlns declarations are preserved on the root element.

Client-Side Only

XML is parsed by the browser's DOMParser locally. SOAP responses, signed SAML assertions, and credential-bearing XML never leave the device.

Common use cases

  • check_circleConverting SOAP API responses to JSON for use in React, Vue, or vanilla JavaScript front-ends
  • check_circleMigrating legacy XML configuration files (Spring, Hibernate, Log4j) into JSON for modern tooling
  • check_circleTransforming RSS and Atom feeds into JSON for a custom news reader or content aggregator
  • check_circleImporting XML data exports into MongoDB, DynamoDB, or any JSON-document database
  • check_circleBridging SAML assertion XML to JSON for inspection in JWT-style debugging tools
  • check_circleConverting Maven pom.xml or Microsoft .csproj files to JSON for tooling and dashboards
  • check_circleBuilding test fixtures from real XML traffic captured by a SOAP debugging proxy
  • check_circleInspecting the structure of OpenAPI/WSDL XML before generating client SDKs

XML vs JSON — when to convert

XML is more expressive — it carries attributes, mixed content, comments, processing instructions, and a formal schema (XSD). JSON is simpler — only objects, arrays, primitives. Convert when your downstream consumer is JavaScript, MongoDB, or a REST API: those expect JSON natively. Keep the XML when you need XSD validation, XPath queries, or document-oriented features like CDATA. The OpenFormatter converter is the right pick for ad-hoc, one-shot conversions where a full XSLT pipeline would be overkill.

Need to do more with XML?

Validate, beautify, or convert XML to other formats — all browser-side.

Frequently Asked Questions

How are XML attributes represented in the JSON output?

XML attributes are emitted as JSON keys prefixed with "@". For example, <book id="b-001"> becomes "@id": "b-001" inside the book object. This is the convention used by Microsoft, Badgerfish, and most XML-to-JSON libraries — it lets attributes coexist with child elements and the element's text content without name collisions.

What happens to XML namespaces during conversion?

Namespace prefixes are kept verbatim in the JSON keys. <dc:title> becomes "dc:title": "...". The xmlns:dc declaration on the root element is preserved as "@xmlns:dc". This keeps the data round-trippable and avoids ambiguity when the same local name (e.g. title) appears in multiple namespaces.

Are CDATA sections preserved or unwrapped?

The DOM parser unwraps the CDATA wrapper and exposes the inner text as the element's textContent — exactly what most consumers want. So <description><![CDATA[a & b]]></description> becomes "description": "a & b" in the JSON. The literal markup characters inside the CDATA are kept as-is, not re-escaped.

How does the converter handle repeated sibling elements?

When the same tag name appears more than once at the same level, the values are collected into a JSON array. A single <author> becomes "author": "Andy Hunt"; two <author> elements become "author": ["Andy Hunt", "Dave Thomas"]. This matches how kubectl, Spring, and most XML-aware libraries treat repeated children.

What about mixed content — elements with both text and child elements?

When an element contains both a text node and child elements, the text is emitted under the "#text" key alongside the child element keys. This is lossy in one direction (whitespace ordering between siblings is not preserved) but it keeps the JSON tree well-formed and easy to consume.

Will the output round-trip back to the original XML?

For data-style XML (config files, SOAP responses, structured records) the round-trip is faithful when you use a JSON-to-XML tool that respects the @-prefix and "#text" conventions. For document-style XML with significant whitespace, processing instructions, or comments, those non-element nodes are dropped — JSON has no equivalent.

Is my XML uploaded to a server during conversion?

No. The conversion uses the browser's built-in DOMParser entirely on your machine. SOAP envelopes, signed SAML assertions, internal API responses, and credential-laden XML never leave your device. Open DevTools → Network and click Convert to verify.

How do I convert SOAP XML responses to JSON?

Paste the full SOAP envelope (<soap:Envelope>...</soap:Envelope>) and click Convert. The result is a deeply nested JSON object reflecting the envelope, header, and body structure. To extract just the payload, drill into result["soap:Envelope"]["soap:Body"] in your code — or strip the envelope before pasting.

XML to JSON Converter Online — Free & Fast | OpenFormatter