About the XML to JSON Converter
Many older APIs, RSS feeds and config files use XML, while modern code prefers JSON. Convert in either direction with predictable rules that you can map back.
XML still powers RSS feeds, SOAP APIs, Office documents, sitemaps and many government and banking interfaces, while modern applications prefer JSON. Converting between them needs predictable rules for attributes, repeated elements and mixed content, otherwise data is lost or structured inconsistently.
This converter uses clear, reversible rules: attributes become keys prefixed with @, text in elements with attributes or children is stored under #text, and repeated elements become arrays. Values stay as strings, because XML has no data types, which protects IDs and leading zeros. Convert JSON back to XML with the same rules.
Because the rules are consistent in both directions, JSON produced here can be turned back into equivalent XML with the JSON → XML mode, which is handy when you edit data in JSON and need to send it to an XML-based system again.
How to use the XML to JSON Converter
- 1Choose XML → JSON or JSON → XML.
- 2Paste your data or load the sample.
- 3Copy or download the result.
Key features
- XML to JSON and JSON to XML.
- Attributes as @keys.
- Repeated elements as arrays.
- #text for mixed content.
- Values kept as strings.
Practical uses
- Reading an RSS feed in JavaScript.
- Converting SOAP responses for a REST app.
- Inspecting sitemap data.
- Creating XML for legacy systems.
- Turning an exported product feed into JSON for a web shop import.
- Converting a simple config file from an older Java or .NET application into JSON.
Example
<book id="b1"><title>Clean Code</title></book> becomes {"book":{"@id":"b1","title":"Clean Code"}}.
Tips and common mistakes
- Convert numbers in your own code where needed.
- Check namespace prefixes, which are kept in key names.
- Use the XML Formatter first to inspect messy XML.
- Validate the XML first with the XML Formatter if the converter reports an error.
Limitations
- Element order across different names is not preserved in JSON objects.
- DTDs and processing instructions are ignored.
Privacy
Conversion runs locally.
Frequently asked questions
How are attributes converted?
An attribute id="b1" becomes "@id": "b1". Text inside an element that also has attributes or children is stored under "#text".
What happens to repeated elements?
Two or more elements with the same name become a JSON array.
Are numbers converted?
No. XML has no data types, so values stay strings. This keeps leading zeros and long IDs safe.
Why is a single element not an array?
Only repeated elements become arrays. Your code should handle both a single object and an array if counts vary.
How is the XML root element chosen?
If your JSON has a single top-level key, it becomes the root element. Otherwise everything is wrapped in a <root> element, because XML needs exactly one root.
Is CDATA supported?
CDATA content is read as normal text, so its contents appear as the element’s value.