Home › File & PDF Tools › XML to JSON Converter
XML to JSON Converter
This free XML to JSON converter turns XML text into clean, readable JSON in your browser. Paste your XML, press Convert, and get pretty-printed JSON you can copy or download. It also checks your XML as it goes, so it doubles as a quick XML validator — if the XML is broken, it tells you exactly where the problem is.
How it works
XML and JSON describe the same kind of data — nested information with names and values — but they speak different dialects. XML wraps values in tags, like <to>Alice</to>. JSON uses curly braces and colons, like "to": "Alice". Modern web code, APIs, and JavaScript work with JSON far more easily, so developers often need to move data from the older XML format into JSON. That is exactly what this converter does, and it does it entirely in your browser.
The conversion follows a few clear rules. Every XML element becomes a JSON key with the same name. Text inside an element becomes its value, so <to>Alice</to> becomes "to": "Alice". When an element appears more than once — for example, three <item> tags inside a list — the converter groups them into a JSON array, so nothing is lost and the order is kept. Attributes are kept too, under a key that starts with @, so <item id="1"> becomes an object with an "@id" of "1" alongside its text. That way the output keeps everything the XML had, just in JSON shape.
The output is pretty-printed with two-space indentation, so it is easy to read and to paste into code, a config file, or an API test. Use the Copy button to grab it, or the Download button to save it as a .json file. If you work with the data in JavaScript, the output is ready to use as an object literal — just remove the outer quotes if you paste it directly into code, or keep it as a file and load it with your usual JSON tools.
The converter also validates your XML while it works. XML is strict: every opening tag needs a matching closing tag, tags must nest properly, and a single root element must wrap everything. If any of those rules is broken, the parser reports an error and the validation line shows the message, including the line and column where the problem was found in most browsers. Fix that spot and convert again. That makes this page useful as a quick XML validator too, even when you do not need the JSON at all.
A few honest limits. The converter does not keep XML comments, processing instructions, or CDATA sections as separate items — CDATA text is treated as ordinary text, which is what most JSON uses need. Namespaces are kept as part of the tag name, so <ns:item> becomes a key called "ns:item". And very large documents — tens of megabytes of XML — may be slow in a browser tab; for those, a command-line tool is a better fit. For the everyday job of converting a feed, a config file, or an API response, this page is the fastest route.
Worked example
A developer receives a small XML message and needs it as JSON for a JavaScript app:
Step 1: Paste the XML into the input box:
<note><to>Alice</to><from>Bob</from><body>Hi</body></note>
Step 2: Press Convert to JSON.
The validation line reports Valid XML, and the output is {"note": {"to": "Alice", "from": "Bob", "body": "Hi"}}. The developer copies it straight into the app, where note.to gives "Alice" with no extra parsing work.
FAQ
Is my XML uploaded anywhere?
No. The conversion runs entirely in your browser using the built-in XML parser. Your data never leaves your device, so private configs, feeds, and API responses stay private.
How are repeated elements handled?
Repeated elements with the same name become a JSON array. For example, three <item> tags inside a list become "item": [ ... ] with all three values kept in order, so nothing is lost.
What happens to XML attributes?
Attributes are kept under keys that start with @. For example, <item id="1">Book</item> becomes an object with "@id": "1" and the text value, so the attribute information survives the conversion.
Why does it say my XML is invalid?
The most common causes are a missing closing tag, tags closed in the wrong order, or more than one root element. The validation line shows the parser's error message, which usually names the line where the problem is — fix that spot and convert again.