Inspect XML as an ordered node tree rather than a guessed object
Understand what this XML-to-JSON mapping represents
This tool converts supported XML into a documented ordered node-tree representation encoded as JSON. It does not guess a business object by turning every element name into a property or discarding repeated children. The top level is a document object with an ordered children array. Element nodes carry their type, name, attributes array and children array. Other node kinds represent text, CDATA, comments, processing instructions or declarations. This explicit structure is useful when order and mixed content matter, but it is not necessarily the JSON shape expected by an application's API.
A common reason to inspect XML this way is to understand exactly where an identifier, attribute or text segment lives before writing an adapter. The mapping keeps an attribute separate from a child element instead of choosing a naming convention on your behalf. An id spelled 007 remains a string value, not an inferred integer. If a receiving API wants a compact record with id and message fields, that requires a separate deliberate transformation. Do not describe this node tree as an automatic schema migration simply because the result is valid JSON text.
The focused page supplies XML as the source format and JSON as the target. It parses a supported document and returns the explicit tree. It does not run a schema, call a web service or decide whether an element has the business meaning suggested by its name. Keep the original XML beside the result while you inspect the mapping. A long generated object can be accurate yet unsuitable for direct submission to a consumer expecting another shape. Confirm the target contract before copying the tree into an application integration.
Trace one attribute and one text value
Checked synthetic input
<root id="007">tea & cake</root>Exact observed output
{
"type": "document",
"children": [
{
"type": "element",
"name": "root",
"attributes": [
{
"name": "id",
"value": "007"
}
],
"children": [
{
"type": "text",
"value": "tea & cake"
}
]
}
]
}The worked source is a root element with id attribute 007 and text tea & cake. The JSON result has a document node, one element node named root, an attribute entry with name id and string value 007, and one text child whose value is tea & cake. The entity spelling in XML is decoded into the actual text character in the node value. The exact code blocks below show the complete mapping. The diagram identifies where the attribute and text reside instead of pretending the result is the simpler object a business API might prefer.
Notice that the attribute value retains its leading zeroes. The converter does not infer numbers, booleans or dates from XML character data. A numeric-looking value can be an identifier, and that interpretation belongs to the application rather than a generic parser. If you build a separate adapter, write explicit rules for any type changes and test them with real requirements. Do not silently coerce a text node to a number because it happens to contain digits in one sample. The same element can contain a different textual specimen in another valid document.
Mixed content demonstrates why ordered children are useful. In a checked paragraph containing text before a bold child and text after it, the tree records the first text node, the b element and the final text node in that order. Their spaces remain part of the values. Collapsing that representation into an unordered name-to-value object could lose where the emphasized word belonged. The node model avoids guessing that simplification. Use the separate XML Formatter to inspect serialization, and remember that converting back requires the documented tree shape rather than an arbitrary JSON object with convenient property names.
Know the normalization and supported subset
The XML input profile requires one root and applies XML 1.0 character rules. It rejects DTD/custom entities and external resources, unbound prefixes, duplicate attributes, mismatched tags and forbidden controls. Namespace declarations and qualified names remain represented, but they do not trigger a schema fetch. This operation is not XSD, SOAP, WSDL or RSS validation. An accepted tree says what this parser represented from the source; it does not establish that a document follows an external vocabulary or that a service is authorized to act on its content.
The parser normalizes XML line endings and literal attribute whitespace, and declaration or processing-instruction spacing can change through representation and serialization. The mapping preserves ordered node information within its model, not every original byte or lexical choice. Original entity spelling and quote style need not survive as independent fields. Text must already be decoded correctly before it reaches the parser; an XML encoding declaration does not make an already decoded browser string into a raw byte-transcoding operation. Keep the authoritative original when those source details are important to an audit or archival task.
The shared XML bounds are 100,000 input UTF-16 code units, 10,000 nodes and attributes, 40 element levels and 1,000,000 output characters. Optional local text-file import is separately limited to 100,000 bytes. JSON representation adds explicit property names, arrays and node descriptors, so the output can be much longer than the source. Do not infer that every accepted XML input must fit every later JSON consumer's limits. Counters in a reverse operation can also measure different structures. Use representative fixtures and review the actual target rather than treating this mapping as an unrestricted round-trip guarantee.
Build an adapter with explicit decisions
For a data integration investigation, identify a few fields and trace them through the tree before designing a compact application object. Record whether each value came from an attribute, a text node or a repeated child. Decide how absent, empty and repeated elements should be handled based on the receiving schema, not on guesswork. This tool supplies the representation needed to inspect those distinctions; it does not make the adapter's policy decisions. Keep synthetic examples that cover order and leading-zero identifiers so future changes do not accidentally collapse important differences.
For a support report, retain the exact XML, generated tree and intended consumer shape as separate artifacts. Explain the mismatch precisely if an API rejects the tree: the problem may be that it expects a domain object, not that the XML parser produced invalid JSON. Copy and Download hand off generated JSON text, not a ready-made business mapping or proof of successful delivery to another service. Verify the actual payload and downstream contract in the appropriate authorized environment. Do not paste private records into a demonstration when a small synthetic tree can show the same structural issue.
For a teaching example, use the diagram and its text equivalent to explain the path from document to element, attribute and text. Check the displayed JSON against the exact source and preserve the original order. The useful endpoint is a transparent representation you can reason about and test, not a claim that all XML has one universally correct JSON object form. Application semantics, schema validation, security, byte preservation and publication remain separate responsibilities. That separation makes the conversion useful without promising an automatic migration it does not perform.
Supporting reference: XML language context; JSON node mapping is tool-specific.
Related existing tool: xml formatter.