Convert XML to JSON Online
Parse XML into clean JSON — attributes, namespaces, repeated elements, and CDATA sections all handled correctly.
XML → JSON
Free XML to JSON converter. Paste any XML and get clean, formatted JSON. Handles attributes, namespaces, repeated element detection, and CDATA. Works in your browser.
Output will appear here
How to use the XML → JSON
Paste or upload your XML data
Paste text directly into the input box, drag and drop a file onto it, or click "Upload file" to browse. Conversion starts instantly on paste — no button click required.
Configure options (optional)
Open the Options panel to customise delimiter, headers, nested-object flattening, and more. Use the Field Selector to pick exactly which columns appear in the output.
Copy or download your JSON
Click Copy to grab the result, or Download to save the file. Everything runs locally in your browser — no data ever leaves your device.
Example
Input (XML)
<root>
<item><id>1</id><name>Alice</name></item>
</root>Output (JSON)
[
{ "id": "1", "name": "Alice" }
]Frequently Asked Questions
- Is my data safe?
- Yes. Every conversion runs entirely inside your browser. No data is ever transmitted to a server. The tool works offline once loaded.
- What is the maximum file size?
- There is no hard limit. Files under 1 MB convert instantly. Files 1–10 MB show a progress indicator. Files over 10 MB prompt a warning and run in a background thread to keep the browser responsive.
- Why does my XML fail to parse?
- Common causes are trailing commas, single-quoted strings, unquoted keys, or missing closing brackets. The converter auto-repairs many of these and tells you exactly what it changed.
- Can I convert multiple files at once?
- The tool handles one file at a time. For bulk conversion, consider the csvjson CLI or API.
Related Converters
How it works
Attributes become nested properties
XML attributes like <item id="1" class="active"> are represented as @_id and @_class keys inside the element's JSON object — preserved, not discarded.
Repeated elements become arrays automatically
If <item> appears 10 times at the same level, the parser collects them into a JSON array of 10 objects. A single <item> stays as an object — no manual wrapping needed.
Namespace prefixes are stripped
Namespace prefixes like soap: and ns0: are removed from element names by default, producing clean keys. The namespace URI declarations in attributes are preserved.
Example
RSS feed parsed to JSON for a content aggregation pipeline
<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>Tech News</title>
<item>
<title>New JS Framework Released</title>
<pubDate>Mon, 01 Jan 2024 00:00:00 GMT</pubDate>
</item>
<item>
<title>TypeScript 6 Announced</title>
<pubDate>Tue, 02 Jan 2024 00:00:00 GMT</pubDate>
</item>
</channel>
</rss>{
"rss": {
"channel": {
"title": "Tech News",
"item": [
{ "title": "New JS Framework Released", "pubDate": "Mon, 01 Jan 2024 00:00:00 GMT" },
{ "title": "TypeScript 6 Announced", "pubDate": "Tue, 02 Jan 2024 00:00:00 GMT" }
]
}
}
}Two <item> elements at the same level are automatically detected and collected into a JSON array — no configuration needed.
Edge cases, handled
Single vs. repeated elements
A single <item> produces an object. Two or more produce an array. This is the most common source of XML-to-JSON bugs — the parser handles it automatically.
Attributes preserved as @_ keys
<tag id="1"> becomes { "@_id": 1, ... }. Attributes are never silently dropped — they appear as @_attrName keys alongside child element keys.
Mixed content (text + elements)
When an element has both text content and child elements, the text is stored under a special #text key alongside the child element keys.
Frequently asked questions
How are XML attributes represented in the JSON output?
Attributes are preserved as @_attrName keys inside the element's JSON object. For example, <item id="1" type="product"> becomes { "@_id": 1, "@_type": "product", ... }. No attribute data is lost.
How are XML namespaces handled?
Namespace prefixes (like soap:, ns0:, xsi:) are stripped from element names by default, producing clean JSON keys. The namespace URI declarations that appear as xmlns attributes are preserved in @_ keys.
Why does my single <item> element not become an array, but two <item> elements do?
XML-to-JSON parsers face an ambiguity: a single element looks like an object, but repeated elements of the same name should be an array. The parser auto-detects this — one element stays as an object, two or more become an array. This is the standard behavior.
How is CDATA content handled?
CDATA sections (<![CDATA[...]]>) are treated as text content and appear as the element's string value in the JSON output. The CDATA wrapper is stripped — just the raw text is preserved.
I'm converting a SOAP response — what should I expect?
SOAP envelopes produce nested JSON: { "Envelope": { "Header": {...}, "Body": {...} } }. Namespace prefixes like soap: are stripped. The actual data is nested inside Body — extract the relevant child key after conversion.
Related Tools
All conversions run in your browser — nothing is uploaded.
Browse all 26 converters →