Predictable mapping
The JSON must contain exactly one root element. Arrays create repeated XML elements, @ keys become attributes and #text becomes element text.
Bounded and defensive
Input is limited to 10 MB, output structure to 100,000 elements and 128 nesting levels. Invalid XML names and non-scalar attribute/text values are rejected.
Need the reverse conversion? Convert XML to JSON.
Numeric and structural fidelity
Unsafe integers, rounded decimals, null values and array roots are rejected rather than silently changed. XML attributes must be scalar and the document must have one valid root element. This conversion does not preserve JSON number types after an XML-to-JSON round trip.
Arrays and empty objects
Only arrays with at least two entries can map to repeated XML elements without losing the array shape. Empty arrays, single-entry arrays, nested arrays, empty objects and mixed text with children are rejected instead of producing a misleading success. XML does not preserve JSON numeric and Boolean types.
Namespace declarations in JSON
Prefixed names such as p:item require an @xmlns:p declaration on the element or an ancestor. Undeclared prefixes, duplicate expanded attribute names and invalid xml or xmlns rebinding are rejected. The generated XML is parsed again before download.
Tabs and line endings inside XML attributes
For example, a JSON attribute value containing a tab, a carriage return or a newline cannot safely be written as a literal XML attribute: XML parsers normalize those characters to spaces. The converter writes numeric character references instead and validates the generated document. Carriage returns inside element text are also encoded to avoid XML line-ending normalization.
Check the XML with the receiving application
Try a record such as {"root":{"@code":"A B","#text":"line 1 line 2"}}. The XML stores the whitespace with character references, not literal control characters. Reopen the result with a standards-compliant XML parser before relying on exact attribute values. XML still cannot retain the original JSON number and Boolean types. For readable XML, use XML formatting; to inspect the reverse mapping, use XML to JSON.