XML to JSON
How to use
Converts XML into JSON or YAML, keeping attributes and repeated elements. Drop the XML file, choose the indentation, and download.
Step 1 of 4: Upload
- 1
- 2
- 3
- 4
Step 1 of 4 · Upload
- 1Upload
- 2Options
- 3Convert
- 4Download
- Turning an RSS or Atom feed into JSON for a web app
- Converting a SOAP or legacy API response for a modern service
- Reading an XML sitemap or config file in a JavaScript project
- Migrating enterprise XML exports to JSON-based tools
Free and private. Everything runs on your own device, with no account and no uploads.
XML is still the format of RSS feeds, SOAP APIs, sitemaps, Android resources and countless enterprise exports, while most modern code expects JSON. This converter maps XML to JSON using the widely used convention: attributes become "@name" keys, repeated elements become arrays, and element text sits under "#text" when it shares an element with attributes. Numbers and true/false are typed, and the mapping round-trips: JSON produced here converts back to the same XML.
As keys prefixed with @, so <book id="7"> becomes {"book": {"@id": 7}}. The prefix keeps attributes distinct from child elements with the same name.
An element that appears once becomes an object; one that repeats becomes an array. If your code needs a consistent shape, normalise single items to arrays after converting.
Element and attribute names keep their prefixes, such as "dc:title", so no information is lost.
Plain integers and decimals become JSON numbers and "true"/"false" become booleans. Anything that could lose meaning ("007", long IDs) stays a string.
- 1
Add an XML file
Drop any well-formed XML: a feed, sitemap, config or export.
- 2
Choose JSON or YAML
YAML is easier to read by eye; JSON is what code consumes.
- 3
Set indentation
2 or 4 spaces for reading, Minified for the smallest file.
- 4
Convert and download
Malformed XML produces an error naming the problem line.
- ·Validate large XML in the XML Formatter first if conversion reports an error
- ·Use YAML output to review deeply nested XML more comfortably
- ·Converting back with JSON to XML restores attributes from the @ keys