XML to JSON Converter
Parse and convert XML to clean JSON instantly — attributes, namespaces, and nested elements handled.
Last updated: March 25, 2026
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat 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
Paste your XML document into the input area on the left
The JSON output is generated instantly and shown on the right
Toggle "Attributes as @" if you want XML attributes distinguished with an @ prefix
Toggle "Compact Mode" to collapse single-child elements that would otherwise be over-wrapped
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 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>{
"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?
What happens when the same XML element appears multiple times?
Are XML namespaces handled?
What is the difference between XML and JSON for data storage?
Can I convert SOAP XML responses to JSON?
What if my XML is malformed?
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
JSON Workflow
Move between formatting, querying, transforming, and converting structured data without losing context.