XML to JSON Converter

Convert XML to JSON online.

input.xml
output.json

About XML to JSON

Convert XML documents into equivalent JSON - useful when integrating a legacy XML API with a modern JSON-based codebase.

🛠️
How to use it
  1. Paste your XML into the input editor.
  2. Click Convert.
  3. The equivalent JSON appears on the right - copy it with the clipboard icon.
  4. Click Load Sample to see a working example.
💡
Tips & use cases
  • XML attributes are collected under an @attributes key on their element - check the output structure matches what your code expects.
  • See our JSON vs XML guide if you're deciding which format to use going forward.

Convert XML to JSON Online

Paste XML and get equivalent JSON: elements become keys, repeated elements become arrays and attributes are kept in their own object. Use it to bring XML feeds and legacy API responses into JSON-based code.

📐

How XML maps to JSON

  • Elements: each child element becomes a key. The root element itself is not repeated; the output is its content.
  • Repeated elements: siblings with the same name are collected into an array.
  • Attributes: they are grouped under an @attributes key on their element.
  • Text: an element with only text becomes a string. If it also has attributes or child elements, the text is stored under #text.
📦

Common reasons to convert XML to JSON

  • Consuming SOAP or other XML API responses in JavaScript
  • Reading RSS and Atom feeds or XML sitemaps
  • Inspecting XML config files such as pom.xml or .csproj
  • Migrating data from a legacy XML system to a JSON store

XML to JSON FAQ

Where do XML attributes go?

Into an @attributes object on the element. For example <person id="1"> becomes "person": { "@attributes": { "id": "1" }, ... }.

Why is a list sometimes an object instead of an array?

XML doesn't say whether an element is a list. The converter creates an array only when it sees two or more siblings with the same name, so a list with a single entry comes out as one object. Handle both cases in your code if the count can vary.

Are numbers and booleans converted?

No. XML has only text, so values such as 42 or true stay strings in the JSON. Convert them in your own code where you know the intended type.

Is my data uploaded to a server?

No. The XML is parsed and converted entirely in your browser.