Free · without registration
Convert XML and JSON with a clear structure
Convert structured data between XML and JSON. Choose a compact model for simple data or an ordered model that gets text and elements in their order.
Entry and options
Their results
The compact model for structured data
An XML root element becomes a JSON key of the same name. Attributes are under @attributes, simple text next to attributes under #text. Repeated elements of the same name become arrays. Values from XML remain strings, so that, for example, product numbers and leading zeros remain unchanged. Indentation empty space between elements is omitted in the compact model.
Mixed content needs a unique order
For a paragraph with text, a bold word and further text, a pure key-value assignment would lose the order. For this, select the ordered model: nodes contains document nodes, elements consist of name, attributes and children. Text, CDATA, comments and processing instructions are displayed separately. The compact model rejects such cases instead of quietly simplifying them.
Check namespaces and XML output
Namespace prefixes and xmlns declarations are retained. With JSON → XML, exactly one valid root element must be created; prefixes require the appropriate namespace declaration. After generation, the XML is checked again for well-formedness. An XSD test does not take place. DTDs and own entity declarations are not processed.
Conscious boundaries instead of seemingly lossless conversion
XML and JSON have different data models. An original XML declaration, the exact entity spelling and JSON data types cannot always be recovered identically. Large JSON numbers are transferred to XML as exact text. The limit is 500 KB input, 30,000 nodes and 80 levels. All inputs remain local.
Example of classification
<product id="7"><name>Cup</name><name>Cup</name></product> becomes a product object with @attributes.id and a name array in the compact model.
Frequent questions
How are attributes displayed?
In the compact model under @attributes. In the ordered model, each element node has an attributes object.
Why is mixed content rejected?
Only in the compact model: there its order would be ambiguous. Switch to the ordered model.
Can I turn any JSON into XML?
The JSON must correspond to the chosen model. Compactly, it requires a root key, ordered a nodes array.