XML to JSON Converter
Convert XML to JSON in your browser using the built-in DOMParser. Nothing is uploaded.
Pure browser JavaScript — uses the native DOMParser API.
How to use this tool
- Paste XML.
- Click Convert.
- Download the JSON result.
Convert XML to JSON in your browser using the built-in DOMParser. Nothing is uploaded.
How it works
The XML to JSON Converter parses XML markup using the browser's built-in DOMParser and transforms it into a JSON object. This makes XML data from legacy systems, SOAP responses, RSS feeds, or configuration files accessible in JavaScript and modern web applications that prefer JSON.
The converter maps XML elements to JSON keys, text content to string values, and child elements to nested objects. Repeated sibling elements with the same tag name are collected into a JSON array. XML attributes can be mapped to keys prefixed with '@' by convention.
Paste your XML into the input area and click Convert. The resulting JSON appears formatted and ready to copy. The DOMParser used is the same one browsers use to render web pages, so it handles all valid XML correctly.
Nothing is uploaded to any server. You can safely convert XML that contains authentication credentials, personally identifiable information, or proprietary business data.
Worked example
Convert an RSS feed to JSON for processing in JavaScript
- Fetch an RSS feed XML from your news source or copy it from a file.
- Paste the XML into the converter input.
- Click Convert.
- Copy the JSON output.
- Use JSON.parse() in your JavaScript to work with the feed items as plain objects.
A JSON object where each item element becomes an entry in a JSON array with title, link, and description as string properties.
Common mistakes to avoid
- Pasting XML with an unresolved namespace prefix without a matching xmlns declaration -- the DOMParser may reject this as malformed XML.
- Assuming all sibling elements with the same tag are automatically collected into an array -- if there is only one instance of a tag, it maps to an object, not an array. Handle both cases in your code.
- Forgetting that XML text nodes containing only whitespace (indentation) may appear as empty string values in the JSON -- filter them out if they are not meaningful.
Key terms
- DOMParser
- A browser API that parses HTML or XML strings into a DOM tree, the same representation used internally for web pages.
- XML attribute
- A name-value pair inside an XML opening tag (e.g.
). Attributes are often mapped to JSON keys with a special prefix like '@'. - SOAP response
- An XML-formatted response from a SOAP web service. Converting SOAP responses to JSON is a common integration task when bridging legacy and modern systems.
Frequently asked questions
- How are repeated elements handled?
- Repeated sibling elements with the same tag are collapsed into a JSON array automatically.