XML โ JSON converter
Convert in either direction. Attributes become @keys, repeated elements become arrays.
Why XML and JSON do not map one to one
XML has attributes, mixed text and repeated elements; JSON has objects, arrays and scalars. Every converter has to choose a convention. This tool uses the common one: attributes get an @ prefix, text content alongside attributes or children is stored as #text, and repeated siblings become arrays.
That means a conversion round trip preserves the data, but the JSON shape of an element that appears once and one that appears many times differs. If you consume the JSON in Java, deserialize with a type that accepts both a single value and a list.
Frequently asked questions
How are XML attributes represented in JSON?
As keys that start with @, for example {"item": {"@sku": "A", "#text": "Pen"}}. Text mixed with attributes or children goes under #text.
What about repeated elements?
Repeated sibling elements with the same name become a JSON array. A single element stays a plain value, so the shape can change with the data; check for that in your code.
Does it handle namespaces, CDATA and entities?
CDATA, comments and the five standard entities plus numeric references are handled. Namespace prefixes are kept as part of the name.
Is this safe for confidential XML?
Yes. The conversion runs in your browser; nothing is uploaded.