XML to JSON
Convert XML to JSON — attributes become @keys and repeated elements become arrays.
Paste or drop
Paste text below, or drop a file instead.
Choose an output
Convert XML to JSON — attributes become @keys and repeated elements become arrays.
Fine-tune
Optional — sensible defaults are already set.
About XML to JSON
This converter parses XML and turns it into a JSON object whose top-level key is the root element's name. Attributes become keys with a configurable prefix (@ by default), child elements become nested keys, and elements that repeat under the same parent are collected into arrays.
When it helps
- Working with an RSS or Atom feed, sitemap or SOAP response in JavaScript or jq.
- Converting an Android layout, Maven POM or SVG file to JSON to inspect its structure.
- Migrating data from an XML export into a JSON-based API or document database.
Tips
- Text inside an element that also has attributes or children is stored under #text.
- An element that appears once is an object or string, not a one-item array. Code that reads the result should handle both shapes if the count can vary.
- All values stay strings. Numbers and booleans in the XML are not converted, because XML has no types without a schema.
- Change the attribute prefix to something like _ or attr_ if @ keys are awkward to access in your code, but make sure it cannot collide with child element names.
Good to know
Quick answers about xml to json in your browser.
No. Comments, the XML declaration and processing instructions are dropped. CDATA sections are kept as text.
Not exactly. Attribute versus element information is kept through the prefix, but comments, whitespace and the distinction between a single element and a one-item list are lost.
Yes. There is no sign-up, no watermark and no limit on how many files you process.
No. Files are read and processed locally in your browser, so they never leave your device.
Related tools
Part of the JSON, YAML & XML Tools collection.