Last updated
Common XML to JSON Conversion Use Cases
- Integrating legacy SOAP services with modern REST clients
- Processing RSS and Atom feeds in JavaScript applications
- Migrating XML configuration files to JSON format
- Converting Android XML resources for cross-platform use
- Transforming XML data exports from enterprise systems
- Working with XML-based APIs from banking and government systems
Data Privacy Note
All conversion happens entirely in your browser. Your XML data is never uploaded to any server, making this tool safe for confidential business data, personally identifiable information, and internal configuration files.
Examples
Example 1: Simple XML to JSON
A basic XML document with elements and text content converts to a straightforward JSON object.
Input XML:
<?xml version="1.0" encoding="UTF-8"?>
<user>
<id>1001</id>
<name>Alice Johnson</name>
<email>alice@example.com</email>
<active>true</active>
</user>
Output JSON:
{
"user": {
"id": "1001",
"name": "Alice Johnson",
"email": "alice@example.com",
"active": "true"
}
}
Example 2: XML Attributes to JSON Properties
XML attributes are converted to JSON properties, typically prefixed with @ to distinguish them from child elements.
Input XML:
<product id="SKU-001" category="electronics" inStock="true">
<name>Wireless Headphones</name>
<price currency="USD">79.99</price>
</product>
Output JSON:
{
"product": {
"@id": "SKU-001",
"@category": "electronics",
"@inStock": "true",
"name": "Wireless Headphones",
"price": {
"@currency": "USD",
"#text": "79.99"
}
}
}
Example 3: Repeated Elements Become JSON Arrays
When the same XML element appears multiple times, the converter automatically creates a JSON array.
Input XML:
<catalog>
<book>
<title>Learning XML</title>
<author>Jane Smith</author>
</book>
<book>
<title>XML in Practice</title>
<author>John Doe</author>
</book>
<book>
<title>Advanced XML</title>
<author>Bob Lee</author>
</book>
</catalog>
Output JSON:
{
"catalog": {
"book": [
{ "title": "Learning XML", "author": "Jane Smith" },
{ "title": "XML in Practice", "author": "John Doe" },
{ "title": "Advanced XML", "author": "Bob Lee" }
]
}
}