XML to JSON Converter

Convert well-formed XML to JSON — character data stays text, attribute names keep their @ prefix.

Input

Well-formed XML 1.0 as text. DTDs, entity expansion and processing instructions are rejected.

The xml-json-v1 mapping

Conversion is deterministic: the same document always produces the same JSON. The rules below are the whole mapping, applied in this order. For a worked namespace walkthrough, seeXML namespaces: prefixes, xmlns, and JSON keys.

XMLJSONExample
character data in a leafJSON string, never a number<unit>001240.50</unit> → "001240.50"
attributekey prefixed with @id="A-1042" → "@id": "A-1042"
namespace declarationattribute too, as @xmlns or @xmlns:pfxxmlns:p="urn:x" → "@xmlns:p": "urn:x"
leaf without attributesthe string itself<qty>2</qty> → "qty": "2"
text plus attributes, no child elementstext under #textsee the sample output
repeated siblings with one qualified nameone array in document ordertwo <item> → "item": [ …, … ]
qualified element namekept verbatim, prefix included<p:width> → key "p:width"
whitespace-only text between childrendropped as indentation—

One child element is not forced into an array, so a document with a single <item> produces an object, not a one-element array. Text together with child elements in one element is rejected as mixed_content_unsupported instead of being flattened, because flattening would lose the order of text and markup.

How a conversion run works

What is rejected

The input must already be decoded text: a declared encoding is not applied. This converter does no XSD validation, XPath, XSLT or XInclude.

Limits of a run

Conversion runs in a Web Worker in this browser tab. Job ids are generated by the page. Cancelling terminates the worker and any answer arriving after that is discarded. A run is stopped after 20 seconds. Error messages name the reason and a position in the document, never a fragment of your text. This page processes the document in this browser and has no document-upload feature. Hosting requests may still produce ordinary service metadata; this is not an absolute privacy guarantee.

Reading the output

Mapping notes are derived from the output you just produced: how many attribute keys were written, how many #text members appeared, how many sibling groups became arrays. Run statisticsreport element, attribute, node and depth counts plus the engine time.Copy JSON and Download JSON export exactly the text in the result pane; if the browser refuses clipboard access the page says so instead of claiming a copy.

Guides

Other reading is indexed in the guides hub.