XML to JSON Converter
Paste XML markup and instantly convert it to clean, structured JSON — handles attributes, nested elements, and arrays
Paste any XML — SOAP responses, config files, RSS feeds, government data exports — and get structured JSON back in one click. Attributes, nested elements, and repeated tags are all handled automatically. And everything runs in your browser. Nothing gets uploaded.
How It Works
The tool uses the browser's built-in DOMParser to read your XML into a tree. It then walks each node — elements become JSON keys, text content becomes string values, and attributes land in an @attributes object. Sibling elements with the same tag name are automatically wrapped in arrays. The result is syntax-highlighted JSON you can copy or save as a .json file.
Examples
Simple product catalog entry
An e-commerce feed with attributes on the root element.
<product sku="A-1042">
<name>Wireless Mouse</name>
<price currency="USD">29.99</price>
</product>
{
"product": {
"@attributes": { "sku": "A-1042" },
"name": "Wireless Mouse",
"price": {
"@attributes": { "currency": "USD" },
"#text": "29.99"
}
}
}
Repeated elements become arrays
Multiple sibling tags with the same name — common in RSS feeds and API responses.
<team>
<member>Alice</member>
<member>Bob</member>
<member>Carol</member>
</team>
{
"team": {
"member": [
"Alice",
"Bob",
"Carol"
]
}
}
Nested config with mixed content
A server configuration snippet — deep nesting with attributes and text nodes together.
<server env="production">
<host>api.example.com</host>
<port>443</port>
<ssl enabled="true">
<cert>/etc/ssl/cert.pem</cert>
</ssl>
</server>
{
"server": {
"@attributes": { "env": "production" },
"host": "api.example.com",
"port": "443",
"ssl": {
"@attributes": { "enabled": "true" },
"cert": "/etc/ssl/cert.pem"
}
}
}
Who Uses This
Converting SOAP or legacy XML API responses into JSON for modern REST endpoints.
Transforming XML data exports into JSON so they can pipe it into Python scripts or dashboards.
Migrating XML config files (Maven, Tomcat, IIS) to JSON-based tooling like Terraform or Docker.
Learning how XML tree structures translate to JSON objects and arrays for coursework.
Common Mistakes
A missing closing tag or unescaped & character will cause the parser to fail. Check your XML is well-formed first — even one unclosed <div> breaks everything.
XML doesn't have native number or boolean types. A <count>5</count> converts to "count": "5" — a string, not an integer. You'll need to cast types in your code after conversion.
If your XML has only one <item> tag, it won't become an array — it'll be a plain object. Two or more sibling tags with the same name trigger array grouping. If your downstream code expects an array, wrap the single value yourself.
Technical Details
- Processing: 100% client-side — XML never leaves your browser
- Browser Support: Chrome, Firefox, Safari, Edge
- Max Input: Limited only by your browser's memory (tested up to 10 MB XML files)
- Output Format: Standard JSON with configurable 2/4-space or tab indentation
Frequently Asked Questions
How do I convert XML to JSON?
Paste your XML into the left panel and click Convert. The tool parses every element, attribute, and text node, then outputs structured JSON on the right. You can copy it to your clipboard or download it as a .json file.
What happens to XML attributes during conversion?
Attributes are placed inside an @attributes object within the element's JSON key. So <book genre="sci-fi"> becomes {"@attributes": {"genre": "sci-fi"}}. You can turn this off if you don't need attributes in your output.
Does XML to JSON conversion lose data?
Element names, text content, and attributes all carry over. What gets dropped: XML comments, processing instructions, namespace prefixes, and DTD declarations. JSON has no equivalent for those. For most real-world data exchange, nothing meaningful is lost.
Are repeated XML elements converted to arrays?
Yes. When two or more sibling elements share the same tag name, they're automatically grouped into a JSON array. A single element stays as a plain object. This is how most XML-to-JSON converters work — it's the standard convention.
Is it safe to convert XML with sensitive data?
Your data stays in your browser the entire time. Nothing is uploaded to a server. The conversion happens client-side using JavaScript, so even if you're working with internal configs or credentials, they don't leave your machine.