Tools
EN

XML to JSON Converter

Paste XML to get JSON instantly. Attributes, text and repeated elements are converted with simple, predictable rules, and options let you control arrays, value types and namespace prefixes.

XML

JSON

Private: your data is processed in your browser and never uploaded.

How to convert XML to JSON

  1. Paste XML, drop an .xml file onto the editor or load it from a URL. The JSON appears as you type.
  2. Adjust the attribute prefix and text key, and decide whether to always use arrays, convert numbers and booleans, or ignore namespace prefixes.
  3. Copy the JSON or download it as a .json file.

How XML maps to JSON

XMLJSON
<name>Ada</name>"name": "Ada"
<price>9.90</price>"price": 9.90 – digits kept exactly
<item id="7">Pen</item>"item": {"@id": 7, "#text": "Pen"}
<tag>a</tag><tag>b</tag>"tag": ["a", "b"]
<note/>"note": null
<![CDATA[a < b]]>the text "a < b"
<soap:Body> with Ignore namespace prefixes"Body"

Why “Always use arrays” matters

An element that appears once becomes a single value, but when it appears twice it becomes an array. Code that reads the JSON then has to handle both shapes – a classic bug when a list sometimes contains only one item. Tick Always use arrays for child elements to get arrays everywhere: the structure is predictable at the cost of a few extra brackets.

XML to JSON in code

Frequently asked questions

Is the conversion lossless?

Element names, attributes and text are kept, and numbers keep their exact digits. Comments, processing instructions and the position of text between child elements (mixed content) cannot be represented in JSON.

Can I convert JSON back to XML?

Yes, with the JSON to XML converter of our sister site JSON Formatter, which uses the same @ and #text conventions.

What happens to namespaces?

Prefixed names such as soap:Body are kept as keys by default, and xmlns declarations appear as attributes. Tick Ignore namespace prefixes to get plain names like Body without the declarations.

Why is a value a string instead of a number?

Values like 007 or 1,000 are not plain decimal numbers, so they stay strings to avoid data loss. Untick Convert numbers and true/false to keep every value as a string.