How to use XML ↔ JSON
- 1
Paste XML or JSON into the Input panel.
- 2
The conversion is performed automatically.
- 3
Use "Swap Direction" to toggle between XML→JSON and JSON→XML.
- 4
Download the output as .json or .xml.
Convert between XML documents and JSON objects in both directions using a recursive browser-native parser.
Paste XML or JSON into the Input panel.
The conversion is performed automatically.
Use "Swap Direction" to toggle between XML→JSON and JSON→XML.
Download the output as .json or .xml.
Yes — XML element attributes are converted to a special @attributes key in the JSON output. These can be re-serialized back to valid XML when converting JSON → XML.
Yes — use the "Swap Direction" button to switch to JSON-to-XML mode. The JSON structure is mapped back to XML elements and attributes.
Namespaces (e.g. xmlns:prefix) are preserved as attributes in the JSON output. If namespaces are important to your use case, verify the output structure matches your schema.
Yes — the browser-native DOMParser handles files of any size. There is no server-side limit. Very large files (50MB+) may be slow depending on available device memory.
XML's tree structure maps to nested JSON objects. Elements with both text content and attributes result in an object with a #text key for the text and @attributes for the attributes. This is standard XML-to-JSON conversion behavior.
No — conversion runs entirely in your browser using the Web APIs. Your data never leaves your device.
XML and JSON both represent structured data — but in very different ways. Modern APIs default to JSON. Enterprise systems, legacy services, SOAP endpoints, and configuration files still use XML. When you need to work with both, converting between them manually is tedious and error-prone.
This tool converts XML to JSON and JSON to XML in your browser. Paste in one side, get the other side. Nothing is uploaded to any server.
XML input:
<user>
<id>1042</id>
<name>Priya Sharma</name>
<email>priya@example.com</email>
<roles>
<role>admin</role>
<role>editor</role>
</roles>
<active>true</active>
</user>
JSON output:
{
"user": {
"id": "1042",
"name": "Priya Sharma",
"email": "priya@example.com",
"roles": {
"role": ["admin", "editor"]
},
"active": "true"
}
}
XML→JSON: An XML DOM parser reads the element tree. Each XML element becomes a JSON key. Text content becomes a string value. Multiple sibling elements with the same tag become a JSON array. Attributes can be mapped to prefixed keys (e.g., @id). The result is a JSON object mirroring the XML hierarchy.
JSON→XML: Each JSON key becomes an XML element tag. Nested objects produce nested elements. Arrays produce repeated elements with the same tag name. Primitive values become element text content.
Key conversion rules:
| XML | JSON equivalent |
|---|---|
Element <name>Priya</name> | "name": "Priya" |
Attribute <user id="1"> | "user": {"@id": "1"} |
| Multiple same-name elements | Array ["val1", "val2"] |
| Text + attributes mixed | {"#text": "...", "@attr": "..."} |
| Numeric text content | String in JSON (XML has no types) |
Integrating with SOAP or legacy APIs: Older enterprise services output SOAP/XML responses. Converting to JSON lets you work with this data in modern JavaScript, Python, or Node.js environments without parsing XML manually.
Data migration: Moving data between systems — a CSV→XML export from an old system needs to become JSON for the new API. Convert incrementally or as a batch.
Config file formats: Some tools use XML configuration (Maven pom.xml, Spring XML config). Converting them to JSON for comparison or documentation purposes is faster with a converter than manual transcription.
**API response comparis...
Looking for a more detailed deep-dive and advanced tips?
Read Full Article on our BlogYour data never leaves this device. All processing is handled locally by JavaScript.
Convert between XML documents and JSON objects in both directions, locally.