XML to JSON Converter
Convert XML into readable JSON, including attributes and repeated elements.
About this tool
Convert XML to JSON in your browser. Attributes become @name keys, text mixed with elements becomes #text, and repeated elements become arrays — three rules stated up front, so the output is never a surprise.
The XML is validated before parsing: a mismatched closing tag or an unclosed element is reported with its line and column, in the same plain-English voice as the rest of the site.
CDATA sections keep their raw content, comments are dropped, and the whole document never leaves the tab.
How to use it
- Paste your XML, or drop an
.xmlfile onto the input pane. - The JSON appears on the right as you type. Repeated elements read as arrays; attributes read with an @ prefix.
- Copy or download. Malformed input gets the exact line and column of the break, not a stack trace.
Worked example
The sample reads version as @version, the server element with its two attributes, and the two admin elements as one array — the three rules of the mapping, one document.
Elements, attributes, repeats
Frequently asked questions
How do attributes come out?
@-prefixed keys: <b c="d">x</b> becomes {"@c": "d", "#text": "x"}. The prefix keeps attributes and elements from colliding, and matches the convention the JSON to XML direction writes.What about repeated elements?
<a> children under one parent become one JSON array: {"a": ["text", "more"]}. A single child stays a plain value — the shape follows the document.Does it handle CDATA and comments?
<![CDATA[keep <this>]]> reads as the string keep <this>. Comments are dropped, which is what JSON conversion convention does with them.