XML to JSON Converter

JSON Tools

How to use the XML to JSON Converter

Convert XML to JSON in 4 steps:

1

Paste your XML

Paste any well-formed XML document — with or without an XML declaration (<?xml version...?>).

2

Choose attribute handling

@prefix maps XML attributes as @id, @class keys (most common). Merge puts attributes directly alongside child element keys. Ignore strips all attributes from the output.

3

Click Convert

Get a structured JSON object matching the XML tree. Repeated sibling tags are automatically grouped into arrays.

4

Copy or use the JSON

Copy the output to clipboard or download as a .json file for use in your application.


When to use this tool

Use XML to JSON Converter when you need to:

  • Convert SOAP API XML responses for consumption in a modern JavaScript or Python application
  • Transform RSS or Atom feed XML into JSON for processing or display in a web app
  • Migrate legacy XML database exports into JSON for a modern API or NoSQL database
  • Process XML configuration files from older enterprise systems in JSON-native tooling
  • Inspect and debug XML API responses by converting them to a more readable JSON structure

Frequently asked questions

Q:How are XML attributes converted to JSON keys?
Three modes are available. @prefix (default) maps each attribute as a key prefixed with @, e.g. @id, @class, @href — this is the most widely recognized convention and matches XMLtoJSON and xml2js defaults. Merge puts attributes directly alongside child element keys with no prefix. Ignore drops all attributes from the output entirely.
Q:How are repeated XML tags handled?
Repeated sibling elements with the same tag name are automatically grouped into a JSON array. For example, multiple <item> elements inside <channel> become an array: { channel: { item: [ ... ] } }. A single <item> remains an object, not a one-element array.
Q:Is CDATA content handled correctly?
Yes. CDATA sections (<![CDATA[...]]>) are extracted as plain string values in the JSON output. The CDATA wrapper is removed and the inner text is treated as the element's text content.
Q:What happens with XML namespaces?
Namespace prefixes are preserved as-is in the JSON keys — e.g. <soap:Body> becomes a key named soap:Body. Namespace declarations (xmlns:soap=...) are treated as attributes and handled according to your chosen attribute mode.
Q:Can I convert an RSS or Atom feed with this tool?
Yes. RSS and Atom feeds are standard XML documents. Paste the feed XML and the tool converts the entire structure to JSON. The <item> or <entry> elements are automatically grouped into arrays, making them easy to iterate in JavaScript or Python.
Q:Why does the converter say my XML is invalid?
The tool uses the browser's native DOMParser, which requires well-formed XML. Common causes of parse errors: unclosed tags, unescaped special characters (use &amp; for &, &lt; for <, &gt; for >), mismatched tag names (case-sensitive in XML), and missing quotes around attribute values.