XML to JSON
Parse XML and convert to a structured JSON object. Scalar values are auto-typed.
2sp · 14px · UTF-8
What is XML?
XML (eXtensible Markup Language) is a text-based format for storing and transporting structured data. It uses self-describing tags similar to HTML: <name>Ravi</name>. Unlike JSON, XML supports attributes, comments, namespaces, and mixed content (text with embedded elements).
Despite JSON becoming the standard for REST APIs, XML is still widely used in enterprise systems (SOAP web services), RSS and Atom feeds, Android manifests, Maven build files, Microsoft Office formats (DOCX, XLSX), and SVG graphics. This tool converts XML documents to JSON so you can work with the data in modern JavaScript, Python, or Go applications.
XML to JSON Conversion Example
Input XML:
xml
<user>
<name>Ravi Kumar</name>
<age>28</age>
<active>true</active>
<role>developer</role>
<role>admin</role>
</user>Output JSON:
json
{
"user": {
"name": "Ravi Kumar",
"age": 28,
"active": true,
"role": ["developer", "admin"]
}
}How Elements Are Converted
| XML pattern | JSON result |
|---|---|
| <tag>text</tag> | "tag": "text" (or typed number/boolean) |
| <parent><child/></parent> | "parent": { "child": null } |
| <item> repeated siblings | "item": [ ... ] (merged into array) |
| <tag/> (empty element) | "tag": null |
| Root element | Becomes the top-level object key |
Common Use Cases
- ▸Legacy API integration — Many enterprise APIs (SOAP, RSS, Atom) return XML — convert to JSON for modern JavaScript consumption.
- ▸Config file migration — Convert Maven pom.xml, Spring context XML or Ant build files to JSON for tooling.
- ▸Data exchange — Receive XML from third-party services and transform to JSON before storing in a database.
- ▸Debugging — Inspect complex XML responses in a structured JSON tree view for easier debugging.