XML ⇄ JSON Converter
About this tool
Convert XML and JSON in both directions with round-trip friendly defaults. Repeated element names stay as scalars until the second occurrence, then become arrays. When a JSON root is an array, the XML side uses <root><item>…</item>…</root>
and converts that shape back into an array when returning to JSON.
XML ⇄ JSON conversion
—
How to use
- Paste XML or JSON into the left input area.
- Choose XML → JSON or JSON → XML.
- Adjust indentation, attribute/text keys, namespace handling, and array treatment as needed.
- Use the Validate buttons to run syntax checks.
Notes
Examples
XML → JSON:
<user id="42">
<name>Taro</name>
<role>admin</role>
<role>editor</role>
</user>
{
"user": {
"@id": "42",
"name": "Taro",
"role": ["admin", "editor"]
}
}
Additional notes
- Attributes are emitted as
[attribute prefix][name]
(default@id
). - Element text content uses
[text key]
(default#text
). - Matching element names remain scalars unless there are two or more values, at which point they become arrays.
- When the JSON root is an array, XML represents it as
<root><item>…</item>…</root>
; the tag name is configurable. - Empty elements with no text or attributes become empty objects
{}
.
Limitations
The tool aims for structural equivalence, but some type fidelity is impossible because XML lacks native booleans or numbers. For example:
Original JSON:
"urls": [
"admin.microsoft.com"
],
"expressRoute": false,
"id": 160,
Round-tripped JSON:
"urls": "admin.microsoft.com",
"expressRoute": "false",
"id": "160",
This happens because the XML representation cannot guarantee array length or preserve boolean/number types without extra annotations.
All processing happens in your browser; no data is sent.