XML to JSON

Parse XML and convert to a structured JSON object. Scalar values are auto-typed.

Input XML
1
JSON Output
Output appears here…
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 patternJSON 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 elementBecomes 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.

Frequently Asked Questions

Not yet — the converter focuses on element content. XML attributes are currently ignored. Use the XML element form to convert attribute-heavy documents.

Sibling elements with the same tag name are automatically merged into a JSON array. This is the most common way XML represents lists.

No. The converter accepts XML with or without the declaration. Plain XML fragments also work as long as there is a single root element.

Yes — use the JSON to XML tool which generates well-formed XML from any JSON object with a configurable root tag.

Related Tools