XML to JSON Converter
Convert XML documents, feeds and API responses into easy-to-use JSON.
XML input
Tab inserts indentation. Press Escape, then Tab, to move focus out of the editor.
JSON output
How to convert XML to JSON
- Paste XML on the left, or open or drop an .xml file.
- The JSON appears on the right as you type.
- Optionally detect numbers and booleans, or always use arrays for child elements.
- Copy the JSON or download it as a .json file.
How XML maps to JSON
The converter uses the widely used convention: elements become keys, attributes get an @ prefix, text next to attributes goes into #text, and repeated elements become arrays. Entities like & are decoded and CDATA is included as text.
<book id="7" lang="en">
<title>XML & You</title>
<author>Ada</author>
<author>Linus</author>
</book>{
"book": {
"@id": "7",
"@lang": "en",
"title": "XML & You",
"author": ["Ada", "Linus"]
}
}Use cases
- Use SOAP or XML API responses in JavaScript, Python or a NoSQL database.
- Convert RSS feeds, sitemaps or product feeds into JSON.
- Migrate XML configuration to JSON-based tools.
Related XML and JSON tools
Convert back with JSON to XML. Explore the source first in the XML viewer or check it with the XML validator; afterwards, tidy or sort the result with the JSON formatter. For config files, try YAML to JSON.
Frequently asked questions
- How are XML attributes represented in JSON?
- As keys with an @ prefix, for example <price currency="EUR">9.90</price> becomes {"price": {"@currency": "EUR", "#text": "9.90"}}.
- When does an element become an array?
- When the same element appears more than once in a parent, such as several <book> entries. Turn on Always use arrays to get arrays even for single elements, which makes code that reads the JSON simpler.
- Are numbers converted?
- By default all text stays a string, because XML has no types and values like 007 would change. Turn on Detect numbers & booleans to convert them.
- What happens to comments and CDATA?
- Comments and processing instructions are skipped. CDATA content is included as normal text.