Move nested data between JSON and XML
Convert nested objects and repeated records with a documented mapping rather than guessing how each format should represent the other. XML attributes use JSON property names beginning with @, and element text alongside attributes uses #text. Repeated child elements become arrays. XML values stay as strings to preserve identifiers and leading zeros. Conversion runs in your browser without loading schemas or external resources. This is a data converter, not a guarantee that every XML document has an equivalent ordinary JSON object.
JSON and XML mapping examples
Create an attribute and a text field
Input
{"@id":"7","zip":"00123"}Result
<?xml version="1.0" encoding="UTF-8"?> <person id="7"> <zip>00123</zip> </person>
The configured root contains an id attribute and a zip child. The @ prefix is a mapping instruction, while the ZIP remains text with its leading zeros. JSON property names must otherwise be supported XML names.
Read repeated XML elements
Input
<people><name>Avery</name><name>Morgan</name></people>
Result
{
"people": {
"name": [
"Avery",
"Morgan"
]
}
}Repeated names become an array in their original group order. Keep the root in JSON is enabled here. Use Always use arrays when the receiving application needs child elements to stay arrays even with a single item.
How to convert JSON and XML
- Paste the source data or open a UTF-8 file. Choose JSON to XML or XML to JSON to match the input.
- For JSON input, choose a root name. Object properties become child elements, @ properties become attributes, and a top-level array uses repeated item elements.
- For XML input, choose whether to keep the root and whether every child element should use an array. These choices determine the shape of the result.
- Review the mapping notes and result summary before copying or downloading. Use the JSON formatter for another readable view when appropriate.
JSON and XML conversion questions
Does this preserve every JSON type?
Ordinary XML does not record JSON types. Numbers and booleans become XML text; null becomes an empty element. Converting that XML back produces strings, including empty text. The summary identifies these changes instead of claiming a lossless round trip.
What happens to empty objects or arrays?
They are flagged because their meaning cannot be represented unambiguously by this mapping. Nothing is silently removed. Supply an explicit structure appropriate for the receiving application before converting those values.
Can I convert XML containing namespaces or mixed text?
Namespaces, mixed text and child elements, and interleaved repeated groups require a custom mapping and are rejected here. Nested data with simple names, attributes, ordinary text, built-in entities, and CDATA text is supported.
Are external entities or schemas loaded?
No. DTDs, custom entities, and processing instructions are rejected. XML comments and formatting whitespace between child elements are omitted. No address inside the input is visited, and neither input nor output is uploaded.
Explicit limits protect the meaning of your data
Names use ASCII letters, digits, underscores, dots, and hyphens, and cannot begin with xml. Invalid XML characters, repeated JSON keys, and duplicate attributes are rejected. The converter limits nesting to 100 levels and bounds nodes, input size, output size, and processing time. Use a dedicated mapping when element order, namespace meaning, document formatting, or exact JSON type recovery is essential.