Convert XML to JSON and back with one documented, stable mapping — attributes, arrays and mixed text included — using DOMParser.
Conversion happens locally in your browser. Your documents never leave your device.
XML to JSON parses with DOMParser and walks the tree with a hand-written recursive converter; JSON to XML walks the object back out. The mapping is fixed and documented below — the same file always produces the same JSON, and the JSON rebuilds the same XML.
"attr" object on their element; repeated sibling elements with the same name become a JSON array; an element that mixes text with children or attributes keeps its text under "#text"; a childless element is just its text string. Sample mapping:<book id="b1" lang="en">
<tag>fiction</tag>
<tag>classic</tag>
Price: 12
</book>
=> {
"book": {
"attr": { "id": "b1", "lang": "en" },
"tag": ["fiction", "classic"],
"#text": "Price: 12"
}
}XML has no array type — repeated <item> elements and a single <item> look identical in shape once you lose the count, and XML has no way to say "this list is always a list" without a schema. Every converter must guess, and the guesses differ. That is why several online converters produce different JSON from the same file; this page picks one documented convention and follows it stably in both directions.
No. It reads the instance document only — elements, attributes and text as written. It will not consult an XSD to decide whether a single-occurrence element should still be an array, nor resolve external entities. If your consumer needs schema-driven mapping, you will need a converter that loads the schema itself.
Everything runs in browser memory, so a file that is tens of megabytes will parse but may feel sluggish when converting, and JSON.stringify doubles the footprint again. For gigabyte feeds, a streaming converter on the server is the honest answer; this tool is built for configuration files, API payloads and document-sized XML.
Within the documented mapping, yes — this tool's own format round-trips: convert to JSON, change a value, convert back, and attributes, repeated elements and text come out in the same shape you started with. Files produced by other converters with different conventions (for example '@' prefixes or '_' for text) may need manual adjustment.
No. Parsing and conversion are plain JavaScript plus the browser's DOMParser, running entirely on your device. Your documents — and any credentials inside configuration XML — never leave your machine.
If you just finished with XML to JSON, the natural next steps are Markdown to HTML, Markdown Live Editor, Markdown Table Formatter, or browse every tool in Privacy File Tools.