Tools

Home
JSON FormatterSQL FormatterJS ValidatorMinify CSS
Merge PDFCompress PDFImage to PDF
JPG to PNGPNG to WebPCrop Image

Convert XML to JSON

Paste XML or upload a file to instantly convert to structured JSON with customizable indentation

Your files never leave your browser
XML Input0 chars, 0 lines
Drag & drop an XML file here, or browse
Accepts .xml files
JSON Output0 chars, 0 lines
Ready·

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

Paste XML
➔
DOM Parse & Walk Tree
➔
JSON Output

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.

INPUT
<product id="4821"> <name>Wireless Mouse</name> <price currency="USD">29.99</price> </product>
OUTPUT
{ "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.

INPUT
<channel> <item> <title>Post One</title> </item> <item> <title>Post Two</title> </item> </channel>
OUTPUT
{ "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.

INPUT
<soap:Envelope xmlns:soap="..."> <soap:Body> <GetUserResponse> <Name>Alice</Name> <Email>[email protected]</Email> </GetUserResponse> </soap:Body> </soap:Envelope>
OUTPUT
{ "soap:Envelope": { "@xmlns:soap": "...", "soap:Body": { "GetUserResponse": { "Name": "Alice", "Email": "[email protected]" } } } }

Who Uses This

💻 Backend Developers

Converting XML API responses to JSON for use in Node.js, Python, or Go services.

📊 Data Analysts

Transforming XML exports from databases or reports into JSON for pandas or spreadsheet import.

🔧 DevOps Engineers

Quick-converting Maven pom.xml or CI config snippets to JSON when migrating build systems.

🎓 Students

Studying how XML structures map to JSON objects for coursework or exam prep.

Common Mistakes

Pasting malformed XML

A missing closing tag or unescaped & triggers a parse error. Check that every opening tag has a match and special characters use entities like &amp;.

Expecting arrays from single elements

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.

Ignoring the @attribute prefix

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

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.

Share: