XML to JSON Converter
Turn XML files, feeds and messages into JSON that is easy to read and use in code. Attributes are kept as @ keys, repeated elements are grouped into arrays, and broken XML gets a clear message instead of a silent failure.
How to Convert XML to JSON
Quick answer: paste your XML or open an .xml file; the JSON appears below. Download it or copy it.
-
1
Add your XML
Paste it or open an .xml file.
-
2
Choose options
Attributes, types and arrays.
-
3
Check the JSON
Errors are explained clearly.
-
4
Download .json
Or copy it.
What You Get
Why Convert XML to JSON?
XML is still common in feeds, exports, office files, configuration and older business systems, but most modern tools and code prefer JSON. Converting XML to JSON makes the data shorter, easier to read and simple to use in apps, scripts, spreadsheets and no-code tools.
How XML Maps to JSON
Each element becomes a key with its child elements nested inside. Elements that appear more than once under the same parent, such as several <book> elements, are grouped into an array. Attributes become keys starting with @, so id="b1" becomes "@id": "b1". When an element has both attributes and text, the text goes into a "#text" key. Empty elements become empty strings, and comments and processing instructions are skipped.
Options Explained
Typed values turns text such as 12.5 or true into numbers and true or false. Always use arrays wraps every child element in an array, even if it appears once, which makes the structure predictable for code that loops over results. Keep the root element name wraps the result in an object named after the root; turn it off to start directly with the root's contents.
Example
The sample catalogue becomes { "catalog": { "@version": "2", "book": [ { "@id": "b1", "title": "The Silent Sea", "price": "12.5" }, … ] } }. With typed values on, the prices become numbers. To go back, use JSON to XML.
Who Converts XML to JSON?
Developers working with feeds and older services, analysts extracting data from exports, e-commerce teams reading supplier catalogues, content managers moving articles between systems and students exploring data formats. Converting in the browser keeps sensitive files private.
When the XML Is Broken
XML must be well-formed: every tag closed, tags properly nested and special characters like & written as &. If something is wrong, the converter shows the browser's description of the problem, often with a line number, so you can fix it. Common causes are a missing closing tag, an unescaped ampersand or text pasted before the first tag.
Good to Know
Namespace prefixes such as media:title are kept in the key names. Whitespace between elements is ignored, but text inside elements is kept as it is, apart from leading and trailing spaces. To tidy the resulting JSON, open it in the JSON Formatter, and to turn it into a spreadsheet, use JSON to CSV.
Real-World Scenarios
A partner sends a daily XML feed of stock levels and you want to load it into a spreadsheet or a no-code automation. Convert it here to JSON, then use JSON to CSV to get a table. Developers debugging an older service paste a response and read it as JSON, which is far shorter. Bloggers moving to a new platform convert the XML export of their old site to inspect posts and categories before importing them. Because the file never leaves the browser, it is safe to convert internal exports that contain customer or pricing details.
Private, Free and Instant
The converter is free and works with files up to 5 MB. There is no sign-up, no row limit beyond the 5 MB file size and nothing to install. The conversion runs in your browser, so customer lists, exports, settings files and other private data are never uploaded or stored. You can open a file from your device, paste data straight from another program, and download the result with the right file extension. It works on Windows, Mac, Linux, Chromebooks, iPhone and Android.
XML to JSON: Mapping Elements, Attributes and Text
XML and JSON describe nested data, but they treat it differently. XML has attributes and mixed text, JSON has arrays and plain values.
Mapping rules
Elements become keys, attributes are stored with a marker such as @ or in a special object, repeated elements become arrays and text content is stored under a text key. Namespaces and comments may be dropped.
Pitfall
A single child element may become an object, while two become an array, so code that reads the result must handle both. For the reverse, use JSON to XML.
Frequently Asked Questions
Questions about XML to JSON