Read XML data the easy way
RSS feeds, sitemaps, SOAP services, office documents and many government and banking systems use XML. Working with XML in JavaScript or Python is more awkward than working with JSON, and deeply nested tags are hard to read. This converter turns any well-formed XML into a JSON structure you can explore, use in code or feed into other tools.
How to convert XML to JSON
- Paste your XML. The declaration line
<?xml …?>is optional. - Keep Convert numbers and true/false ticked to get real numbers and booleans instead of text.
- Tick Always use arrays if your code expects lists even when an element appears only once.
- Click Convert to JSON. If the XML is broken, the parser's error message is shown.
Mapping rules
- Each element becomes a key. An element with only text becomes a simple value:
<year>1999</year>→"year": 1999. - Attributes become keys starting with
@:<book id="1">→"@id": 1. - Repeated elements with the same name, such as several
<book>tags, become an array. - When an element has both attributes or children and text, the text is stored under
#text. - Empty elements become
null. Comments and processing instructions are ignored.
Why does one book become an object but two become an array?
XML has no way to say "this is a list". The converter only knows an element repeats when it sees it twice. That means the same feed can produce an object one day and an array the next. If you are writing code that reads the JSON, tick Always use arrays so every child element is consistently an array.
Frequently asked questions
What does "Invalid XML" usually mean?
A tag is not closed, tags are closed in the wrong order, there is a bare & that should be &, or there is more than one root element.
Are namespaces supported?
Yes. Prefixed names such as dc:title are kept as they are in the keys.
Can I go back from JSON to XML?
Yes, with the JSON to XML converter, which uses the same @ and #text rules.