XML to JSON Converter
Convert XML elements, attributes, text, and repeated siblings into formatted JSON. Parsing runs entirely in your browser.
How to use it
- Paste an XML document, drop a local
.xmlfile, or select Load Example. - Select Convert to JSON or press Ctrl/⌘ + Enter.
- Review how attributes, text, and repeated elements were represented.
- Copy or download the formatted JSON and validate it against your target schema.
XML to JSON example
Consider a catalog with attributes and repeated tags:
<book id="b1">
<title>API Design</title>
<tag>api</tag>
<tag>json</tag>
<price currency="USD">19.99</price>
</book>
The root becomes a top-level book property. Its id attribute is stored under @attributes. The two tag siblings become an array in source order. Because price contains both an attribute and text, its value becomes an object containing @attributes and #text.
Mapping rules
Elements with only text become JSON strings. Nested elements become object properties. Repeated siblings with the same qualified name become arrays. Attributes are grouped under @attributes, and direct text on an element that also has attributes or child elements is stored under #text. XML comments and processing instructions are ignored.
Element and attribute namespace prefixes are preserved in their qualified names, such as soap:Envelope. Namespace declarations are attributes and therefore appear under @attributes. The converter does not invent namespace objects or remove prefixes because doing so could merge names that are distinct in the source document.
Why XML values remain strings
XML text does not carry a built-in JSON-style number, boolean, or null type. The text 00123 might be an identifier, while true might be a literal word. Automatically coercing those values can remove leading zeros or change application meaning. Cryonel preserves element text and attribute values as strings; apply types later using an XML Schema, API contract, or domain rules.
Mixed content and unsupported declarations
Mixed-content XML can interleave text and child elements, as in a document paragraph containing inline markup. A normal JSON object cannot preserve that order without a more verbose node array, so this converter groups child elements and combines direct text under #text. Use a dedicated XML processing pipeline when document order is semantically important.
DOCTYPE declarations are rejected. The tool is intended for API payloads, configuration, feeds, and small data documents rather than DTD processing or entity expansion. Malformed markup is reported as an error instead of returning a partial object.
Security and privacy
The browser’s native XML parser and the conversion logic run in the current tab. Cryonel does not upload the XML or JSON output. The converter does not fetch remote schemas or external resources. Sensitive values can still appear in copied or downloaded output, so handle the result like the original document.
Frequently Asked Questions
How are XML attributes represented in JSON?
Attributes are grouped under an @attributes object so they cannot collide with child element names.
What happens to repeated XML elements?
Repeated sibling elements with the same name become a JSON array in their original order.
Does the converter support XML DOCTYPE declarations?
No. DOCTYPE declarations are rejected to keep this browser conversion narrow and predictable.