Convert XML to JSON
Paste XML or upload a file to instantly convert to structured JSON with customizable indentation
Paste your XML — a config file, an API response, a SOAP envelope — and get structured JSON back in one click. Attributes land under @-prefixed keys, repeated sibling tags become arrays, and you pick the indent style. And everything runs in your browser. Nothing gets uploaded.
How It Works
Your browser's built-in DOMParser turns the raw XML into a document tree. Then the tool walks each node — element names become JSON keys, attributes get an @ prefix, and text nodes land under #text when mixed with other children. If multiple sibling elements share the same tag name, they're grouped into an array automatically.
Examples
Simple product catalog entry
Pulling a single item from an e-commerce XML feed into a JSON-based frontend.
<product id="4821">
<name>Wireless Mouse</name>
<price currency="USD">29.99</price>
</product>
{
"product": {
"@id": "4821",
"name": "Wireless Mouse",
"price": {
"@currency": "USD",
"#text": "29.99"
}
}
}
RSS feed with repeated items
Converting a blog RSS snippet where multiple <item> tags need to become a JSON array.
<channel>
<item>
<title>Post One</title>
</item>
<item>
<title>Post Two</title>
</item>
</channel>
{
"channel": {
"item": [
{ "title": "Post One" },
{ "title": "Post Two" }
]
}
}
SOAP envelope with namespaces
Debugging a SOAP response — you just want to see the payload structure without the angle-bracket noise.
<soap:Envelope xmlns:soap="...">
<soap:Body>
<GetUserResponse>
<Name>Alice</Name>
<Email>[email protected]</Email>
</GetUserResponse>
</soap:Body>
</soap:Envelope>
{
"soap:Envelope": {
"@xmlns:soap": "...",
"soap:Body": {
"GetUserResponse": {
"Name": "Alice",
"Email": "[email protected]"
}
}
}
}
Who Uses This
Converting XML API responses to JSON for use in Node.js, Python, or Go services.
Transforming XML exports from databases or reports into JSON for pandas or spreadsheet import.
Quick-converting Maven pom.xml or CI config snippets to JSON when migrating build systems.
Studying how XML structures map to JSON objects for coursework or exam prep.
Common Mistakes
A missing closing tag or unescaped & triggers a parse error. Check that every opening tag has a match and special characters use entities like &.
If there's only one <item> in your XML, it becomes an object — not an array. The converter only creates arrays when it finds two or more siblings with the same name. Add a wrapper check in your code if you always need an array.
Attributes show up with an @ in front of their name. If you're feeding the JSON into another system, make sure it knows to look for @id instead of just id.
Technical Details
- Processing: 100% client-side — uses the browser's native DOMParser
- Browser Support: Chrome, Firefox, Safari, Edge
- Indent Options: 2, 3, or 4 spaces, or tab characters
- Attribute Convention: Prefixed with
@(e.g.,@id,@class) - File Upload: Drag-and-drop or click to browse (.xml files)
Frequently Asked Questions
How does XML to JSON conversion actually work?
The browser's DOMParser reads your XML into a tree structure. Then the tool walks each node — element names become JSON keys, attributes get an @ prefix, and text content is stored directly as a string value. When siblings share the same tag name, they're grouped into an array.
Can I convert JSON back to XML?
Not with this tool — it's a one-way conversion. For JSON-to-XML, check out our dedicated JSON to XML converter. The two formats don't map perfectly (XML has attributes, JSON doesn't), so round-tripping can lose some nuance.
Is my data safe? Does it get sent to a server?
Your XML stays in your browser the entire time. Nothing is uploaded or stored anywhere. The conversion happens using JavaScript on your device, so even sensitive config files or API keys in your XML won't leave your machine.
What's the maximum file size I can convert?
There is no hard limit since it all runs locally. That said, browsers start slowing down around 10–15 MB of XML depending on your hardware. For anything under 5 MB, you won't notice any delay at all.
Why do some elements become arrays and others don't?
The converter only wraps elements in an array when two or more siblings share the same tag name. A single <item> stays as an object. This is standard behavior for most XML-to-JSON libraries, but it means your code should handle both cases if the number of elements can vary.