XML to JSON Converter
Convert XML to JSON in your browser with a clear, documented mapping. Attributes...Convert XML to JSON in your browser with a clear, documented mapping. Attributes, repeated elements as arrays and raw CDATA are all handled, with copy...
Updated
JSON output will appear here...How the mapping works
<city>Paris</city>{ "city": "Paris" }<a id="1">hi</a>{ "@id": "1", "#text": "hi" }<i>A</i><i>B</i>{ "i": ["A", "B"] }<n><![CDATA[<b>]]></n>{ "n": "<b>" }Quick answer
To convert XML to JSON, paste your XML into the input box and the tool parses it in your browser and shows JSON instantly. Element names become object keys, attributes are prefixed with @ (for example <a id="1"> becomes {"@id": "1"}), text sits under #text, and repeated sibling elements become arrays. CDATA is kept raw and nothing is uploaded, so it works offline and stays private. Choose the indent, then copy or download the .json file.
Converter Features
Why Use XML to JSON Converter?
Instant, Live Conversion
Paste XML and the JSON updates as you type, with your chosen indent. No button to hunt for and no page reloads.
A Clear, Documented Mapping
Elements become keys, attributes are prefixed with @, text sits under #text, and repeated elements become arrays. The rules are shown on the page.
Smart Array Detection
Repeated sibling elements collapse into a JSON array automatically. Prefer arrays everywhere? Turn on Always use arrays for a stable shape.
Keeps CDATA Raw
CDATA content is preserved byte-for-byte and never escaped or trimmed, so markup and characters like < and & inside a block survive intact.
Friendly Error Messages
Malformed XML never crashes the tool. You get a plain-English message with the exact line and column so you can fix it fast.
100% In Your Browser
Every byte is parsed on your device with no upload, so there are no file-size limits, it works offline, and your data stays private.
Common Uses for XML to JSON
API Integration
Convert an XML or SOAP API response to JSON so you can work with it directly in JavaScript.
Data Migration
Transform XML exports into JSON for document databases like MongoDB or for a modern data pipeline.
Config Conversion
Turn an XML config file into JSON for tools and frameworks that expect JSON input.
Feeds & Sitemaps
Convert an RSS, Atom or sitemap.xml document to JSON to inspect or reshape its entries.
How It Works
Paste Your XML
Drop in an XML document, API response, config file or feed. Or hit Load sample to see the converter in action.
Set the Options
Pick 2, 4 or tab indent, toggle the @ attribute prefix, choose whether single children become arrays, and trim text whitespace if you like.
Copy or Download
The JSON updates live. Copy it to your clipboard or download it as a .json file. Everything happens locally in your browser.
Tips for XML to JSON Conversion
Keep the @ Prefix On
The @ prefix keeps attributes and child elements distinct, which prevents key collisions and matches common conventions like those in xml-js and fast-xml-parser.
Use Always Use Arrays for Stable Shapes
If your code maps over children, turn on Always use arrays so a single element and many elements both produce an array, avoiding branchy parsing code.
One Root Element Only
A well-formed XML document has exactly one root element. If you paste several top-level elements, wrap them in a single parent element first.