WebToolsPlanet
converter Tools

XML to JSON Converter

Parse and convert XML to clean JSON instantly — attributes, namespaces, and nested elements handled.

Last updated: March 25, 2026

Client-Side Processing
Input Data Stays on Device
Instant Local Execution

Find this tool useful? Support the project to keep it free!

Buy me a coffee

What is XML to JSON Converter?

XML (Extensible Markup Language) was the dominant data interchange format before JSON took over in the 2010s. Despite JSON's prevalence, XML remains widely used in enterprise systems, SOAP APIs, RSS/Atom feeds, Maven/Ant build files, Android manifests, Microsoft Office file formats (.docx, .xlsx), and government data systems. Being able to convert XML to JSON is an essential skill when integrating with legacy systems or processing data from these domains.

Converting XML to JSON is more nuanced than it appears — XML supports attributes, namespaces, mixed content (text and child elements together), and multi-occurrence elements that JSON's flat object model treats differently. This tool uses a configurable parsing strategy, giving you control over how attributes (typically prefixed as @attr), text nodes (#text), and repeated elements (converted to arrays) are represented in the JSON output.

How to Use XML to JSON Converter

1

Paste your XML document into the input area on the left

2

The JSON output is generated instantly and shown on the right

3

Toggle "Attributes as @" if you want XML attributes distinguished with an @ prefix

4

Toggle "Compact Mode" to collapse single-child elements that would otherwise be over-wrapped

5

Click "Copy JSON" to copy the result, or "Download .json" to save it as a file

Common Use Cases

  • Converting SOAP API XML responses to JSON for use in modern JavaScript applications
  • Parsing RSS or Atom feed XML to extract article titles, links, and publish dates as JSON
  • Converting Android manifest XML (AndroidManifest.xml) to JSON for analysis
  • Transforming Maven pom.xml dependency lists into JSON for processing by scripts
  • Converting government open-data XML feeds to JSON for data visualization
  • Processing SOAP-based legacy web service responses in a Node.js application
  • Transforming Microsoft Office Open XML (DOCX/XLSX) internal XML into readable JSON
  • Debugging SOAP envelope responses by converting them to easier-to-read JSON

Example Input and Output

Converting a typical RSS feed item from XML to a clean JSON object:

XML input
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Tech Blog</title>
    <item>
      <title>How to optimize CSS</title>
      <link>https://example.com/css-tips</link>
      <pubDate>Mon, 25 Mar 2024 09:00:00 GMT</pubDate>
      <description>Learn to minimize your CSS files.</description>
    </item>
  </channel>
</rss>
JSON output
{
  "rss": {
    "@version": "2.0",
    "channel": {
      "title": "Tech Blog",
      "item": {
        "title": "How to optimize CSS",
        "link": "https://example.com/css-tips",
        "pubDate": "Mon, 25 Mar 2024 09:00:00 GMT",
        "description": "Learn to minimize your CSS files."
      }
    }
  }
}

Privacy First

XML parsing runs entirely in your browser. Your XML data — which may contain API keys, credentials, or business data — is never transmitted to our servers.

SOAP to JSON Tip

When converting SOAP responses, look for the contents inside soapenv:Body (or soap:Body). The actual response data is always one level deeper than the envelope. Extract just that key's value from the JSON output for the data you need.

Schema Differences

XML and JSON are not perfectly interchangeable. XML supports comments (lost in conversion), mixed content (text between child elements), and ordered attributes. If exact round-trip fidelity matters (JSON back to identical XML), use a library like xmlbuilder2 or xml2js in your application instead of manual conversion.

Frequently Asked Questions

How are XML attributes represented in JSON?
By default, attributes are extracted as sibling properties prefixed with "@" (e.g., the XML attribute version="2.0" becomes "@version": "2.0" in JSON). This follows the popular xml2js and fast-xml-parser convention. You can toggle attribute handling in the options.
What happens when the same XML element appears multiple times?
Repeated sibling elements with the same tag name are automatically collected into a JSON array. For example, three <item> elements become "item": [{...}, {...}, {...}]. A single <item> becomes an object. This is the expected behavior for most use cases.
Are XML namespaces handled?
Yes. Namespace prefixes (like soapenv:Body or xs:string) are preserved in the JSON key names. Namespace declarations (xmlns:soapenv="...") are treated as attributes and represented as "@xmlns:soapenv" keys.
What is the difference between XML and JSON for data storage?
XML is verbose but supports attributes, comments, mixed content, and document type definitions (XSD/DTD schemas). JSON is compact, maps directly to JavaScript objects, parses faster, and is supported natively by all modern APIs. For new projects, JSON is preferred. For legacy integrations (SAP, Oracle, SOAP), XML is still ubiquitous.
Can I convert SOAP XML responses to JSON?
Yes. Paste a SOAP envelope directly into the tool. SOAP namespaces (soapenv:, xmlns:) will be preserved as prefixed keys. The Body content within the envelope will be correctly nested in the JSON output. You can then navigate to the relevant keys and extract what you need.
What if my XML is malformed?
The tool will report a parse error with the line and character position where the XML is invalid. Common issues include unclosed tags, mismatched tag names, missing quotes around attribute values, and special characters (&, <, >) that should be escaped as &amp;, &lt;, &gt;.

How This Tool Works

The XML input is parsed using the browser's native DOMParser API (parseFromString with text/xml MIME type), which builds a standards-compliant XML Document Object Model. A recursive traversal function walks the DOM tree, converting element nodes to JSON objects, text nodes to string values, attribute nodes to @ prefixed keys, and repeated same-name siblings to arrays. The result is serialized using JSON.stringify() with 2-space indentation.

Technical Stack

Browser DOMParser APIRecursive DOM traversalRFC 4122 attribute conventionClient-side only