XML to JSON converts XML documents into equivalent JSON objects. The converter uses the browser's built-in DOMParser for reliable XML parsing, then recursively walks the DOM tree to produce structured JSON output.
XML attributes are mapped to keys prefixed with @ (e.g., @id, @class). Text content in mixed elements uses the #text key. When multiple child elements share the same tag name, they are automatically grouped into a JSON array.
This is useful for consuming XML APIs, converting legacy XML configs to JSON, or migrating SOAP service responses to a more modern format. All processing happens in your browser — no data leaves your machine.
<user id="42" role="admin"> <name>Alice</name> <email>alice@example.com</email>
</user> // Converts to:
{ "user": { "@id": 42, "@role": "admin", "name": "Alice", "email": "alice@example.com" }
}<items> <item>Apple</item> <item>Banana</item> <item>Cherry</item>
</items> // Converts to:
{ "items": { "item": ["Apple", "Banana", "Cherry"] }
}Repeated elements with the same tag are automatically grouped into arrays.
A single <item> child produces a plain value, while two or more produce an array. If your code always expects an array, you may need to normalize the output. This is a fundamental XML-to-JSON mapping challenge.
XML elements with both text and child elements use #text for the text portion. This can result in unexpected JSON structures if the XML has heavily mixed content.
XML namespace prefixes (e.g., xs:element) are preserved in tag names. The converter does not strip or resolve namespace URIs.
XML to JSON Converter is purpose-built for this single workflow. The copy, examples, and edge cases on this page are written for users who already know they want this specific shape of data.
If you are still deciding between adjacent options, browse the Data Conversion Tools first and come back here once you have ruled out the other pages.
Attributes are prefixed with @ in the JSON output. For example, <book id="1"> produces {"@id": 1}. This convention keeps attributes separate from child elements.
When multiple child elements share the same tag name, they are grouped into a JSON array. A single child with a unique tag becomes a plain value.
CDATA content is treated as text and included in the #text field or as the element's value if there are no child elements.
No. The XML must be well-formed. If the parser detects errors (unclosed tags, invalid characters), you'll see an error message with details about the issue.
Yes. The XML is parsed using your browser's built-in DOMParser. Nothing is sent to any server.
Move between CSV, JSON, XML, YAML, SQL, tables, and developer-friendly formats with converter pages grouped by workflow.
Need more context before using the tool? Start with one of these workflow guides.