How to use
- Click Paste to insert XML from your clipboard, or Upload to select a file.
- Choose an Attribute prefix, or turn on Ignore attributes to leave attributes out.
- Set Arrays to Auto (2+ same tags) or Always.
- Click Convert if it appears; otherwise, conversion updates as you edit.
- Click Copy to copy the JSON, or Download to save a .json file.
Examples
Product catalog with attributes and repeated items
<catalog> <product sku="MUG-101">Blue coffee mug</product> <product sku="MUG-102">White coffee mug</product> </catalog>
{
"catalog": {
"product": [
{
"@sku": "MUG-101",
"#text": "Blue coffee mug"
},
{
"@sku": "MUG-102",
"#text": "White coffee mug"
}
]
}
}Inventory with typed values and a single-item array
<inventory>
<item>
<sku>007</sku>
<quantity>12</quantity>
<available>true</available>
<supplierId>12345678901234567890</supplierId>
<note/>
</item>
</inventory>{
"inventory": {
"item": [
{
"sku": [
"007"
],
"quantity": [
12
],
"available": [
true
],
"supplierId": [
"12345678901234567890"
],
"note": [
null
]
}
]
}
}Namespaced configuration with comments
<cfg:settings xmlns:cfg="urn:example:settings"> <!-- Staging environment --> <cfg:endpoint>https://api.example.com/v1</cfg:endpoint> <cfg:region>us-east-1</cfg:region> </cfg:settings>
{
"@xmlns:cfg": "urn:example:settings",
"#comment": "Staging environment",
"endpoint": "https://api.example.com/v1",
"region": "us-east-1"
}FAQ
Is my XML uploaded when I convert it online?
Your XML is parsed and converted in your browser, not uploaded, and external DTDs or entities are never fetched. Analytics events contain the tool slug, not your XML or JSON.
Can I convert the JSON back to the same XML?
Swap opens JSON to XML with your current attribute prefix and text key, but it is not a lossless round trip. Conversion drops the XML declaration, DOCTYPE and processing instructions, and can lose the order of mixed text and alternating child elements.
Why is my XML not converting to JSON?
Invalid XML leaves the JSON output empty and shows errors with line and column numbers. Click an error message to jump to it; check for mismatched tags, unquoted attributes, unescaped & characters or more than one root element.
How large an XML file can I convert?
Files larger than 50 MB are rejected. Above 1 million input characters, use Convert instead of live conversion; your browser may still run out of memory, so try a smaller file if that happens.
Does the converter support XML entities and CDATA?
It decodes predefined XML entities, numeric character references and entities declared in an internal DOCTYPE subset; CDATA content is taken as text. HTML entities such as are not predefined in XML, so use   for a non-breaking space.