XML to JSON Converter
Paste your XML below and get JSON instantly. The conversion happens entirely on your device — nothing is uploaded — so it's safe for private data and works offline once loaded.
Example: XML → JSON
XML in
<root>
<name>CalcCafe</name>
<tools>json</tools>
<tools>yaml</tools>
</root>
JSON out
{
"root": {
"name": "CalcCafe",
"tools": [
"json",
"yaml"
]
}
}How it works
The converter parses your XML into an in-memory data structure, then serialises that structure as JSON. Because both steps run client-side in JavaScript, conversion is instant and your data never touches a network. The same engine powers every JSON / YAML / XML / CSV pairing, so results stay consistent across directions — you can round-trip XML → JSON and back without surprises.
Tips for clean JSON
- Use the From / To selectors to switch formats, or the ⇄ button to reverse the conversion and reuse the output as input.
- Set the indent to match your project's style (2 or 4 spaces).
- Invalid input shows a clear error message pointing at the problem instead of failing silently.
Good to know
The XML to JSON Converter turns an XML document into an equivalent JSON object directly in your browser. It is built for developers, API integrators, and data wranglers who receive XML from a legacy SOAP endpoint, an RSS feed, a config file, or an export, and need it as JSON to feed into a modern app, a JavaScript front end, or a tool that only speaks JSON.
Reach for it when you want a quick, throwaway conversion without piping sensitive payloads through an unknown web service, when you're debugging an API response and want to eyeball its shape, or when you need a one-off transform during local development. Because everything runs client-side, it's also handy on locked-down machines and works offline once the page has loaded.
To read the output correctly, keep three mapping rules in mind: a single child element becomes a plain key/value pair, repeated sibling elements with the same tag collapse into a JSON array, attributes appear as keys prefixed with @, and any text mixed alongside child nodes lands under a #text key. So an element's "shape" in JSON depends on how many times it appears and whether it carries attributes — the same tag can serialize as a string in one document and an array in another.
A practical caveat: XML and JSON aren't perfectly symmetrical, so a few details don't survive a literal round trip. Comments, processing instructions, namespace prefixes, and the distinction between an empty element and an element containing an empty string can be flattened or dropped, and everything (numbers, booleans, dates) becomes a JSON string unless you cast it afterward. If a single child appears only once, it won't be an array, so write consuming code that tolerates both a single object and an array for elements that may repeat.
Frequently asked questions
How are repeated XML tags handled?
When an element appears more than once under the same parent, the tags are collapsed into a JSON array automatically — so <item>a</item><item>b</item> becomes "item": ["a", "b"].
What happens to XML attributes?
Attributes are kept as keys prefixed with @ (for example "@id"), and mixed text content is stored under a "#text" key, so no data is lost.
Is my data uploaded anywhere?
No. The conversion runs entirely in your browser using JavaScript — your data never leaves your device and nothing is sent to a server.
Is this converter free?
Yes, completely free with no sign-up, and no limits. It even works offline once the page has loaded.
People also ask
How do I convert XML to JSON without uploading my file?
Use a client-side converter like this one, which parses and serializes the data entirely in your browser using JavaScript. Nothing is sent to a server, so the file never leaves your device.
Why does a single XML element become an object but repeated tags become an array?
The converter can only tell an element repeats by seeing it more than once under the same parent. A tag that appears once stays a single value or object, while two or more siblings with the same name are grouped into an array.
Can I convert the JSON back into the original XML?
You can convert JSON back to XML with a paired tool, but the result may not be byte-for-byte identical. XML-only details like comments, namespaces, and processing instructions are not preserved in JSON, so they cannot be restored.
Are numbers and booleans in XML converted to real JSON numbers?
No. XML has no data types, so text such as 42 or true is converted to a JSON string by default. You need to cast or parse those values yourself after conversion if you require real numbers or booleans.
How are XML namespaces handled when converting to JSON?
Namespace-prefixed tags such as ns:item are typically kept as part of the key name, but the namespace declaration itself is not given special meaning in the JSON. The output treats the prefixed name as an ordinary string key.
What is the difference between XML and JSON?
XML is a markup language that uses nested tags and attributes and is verbose, while JSON is a lightweight data format built from objects, arrays, strings, numbers, and booleans. JSON is generally smaller and maps directly to data structures in most programming languages.
Does converting large XML files in the browser cause performance problems?
Very large files can be slow or memory-heavy because the whole document is parsed into memory at once before being serialized. For typical API responses and config files this is instant, but multi-megabyte files may take noticeably longer.
Why do some keys in my JSON output start with @ or #text?
Keys beginning with @ represent the XML element's attributes, and the #text key holds character data that sits alongside child elements. This convention ensures attributes and mixed content are preserved rather than discarded.
Related converters