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."
}
}
}
}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
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 &, <, >.
JSON Workflow
Move between formatting, querying, transforming, and converting structured data without losing context.
Related Tools
JSON to XML Converter
Convert JSON to XML online. Nested objects and arrays are mapped to XML elements with configurable root element name and optional XML declaration.
XML to JSON Schema Converter
Generate JSON Schema from XML by normalizing elements and attributes into JSON, inferring scalar types, and emitting Draft 2020-12 or Draft 07 schema.
SOAP to JSON Converter
Convert SOAP XML envelopes to clean JSON. Automatically strips the SOAP wrapper and extracts the body content for SOAP 1.1 and 1.2 messages.
WSDL to JSON Converter
Parse WSDL web service definitions and convert them to structured JSON. Extracts operations, messages, port types, bindings, and service endpoints.
TOML to JSON Converter
Convert TOML configuration files to JSON format. Supports tables, arrays, inline tables, multi-line strings, and all TOML data types.
XML Converter
Convert XML to JSON, YAML, CSV, TSV, or HTML table. Paste any XML and choose your output format instantly in the browser.

