Skip to content

XML to JSON

Turn XML into JSON, attributes and repeated elements included.

How to convert XML to JSON

Three steps, all in your browser.

  1. 1

    Paste or open your data

    Drop a file or paste rows straight into the input box.

  2. 2

    Check the options

    Delimiter, header row, indentation: the output updates live.

  3. 3

    Download

    Save the converted file, or copy the output.

XML to JSON: what to know

XML marks up data with nested elements and attributes. It's still common in feeds, office files, government data and older APIs, while most modern code expects JSON. This converter reads XML in your browser and writes the equivalent JSON.

Each element becomes a key, and nesting is kept. Attributes are kept as keys that start with @_, and when an element has attributes as well as text, the text goes under #text. Elements that repeat under the same parent become arrays, while a single element stays an object. CDATA sections become plain text, entities such as & are decoded and surrounding whitespace is trimmed. With typed values on, text that round-trips as a number or boolean, such as 42 or true, becomes a JSON number or boolean, while 007 or 9.50 stay strings. Comments and processing instructions are dropped.

The XML is checked before it's converted. If a tag is left open or closed in the wrong order, you get a short description of the problem with its line and column instead of a half-converted file.

Popular uses

  • Using RSS feeds, sitemaps or XML exports in JavaScript
  • Moving data from an XML-based API into a modern app
  • Reading the structure of an unfamiliar XML file
  • Preparing XML data for a JSON database

Tips for the best result

  • If an element sometimes appears once and sometimes several times, handle both an object and an array in your code.
  • Turn off typed values to keep every value as a string.
  • Convert to CSV instead when you want the first repeated element list as a table.

Read how JustYourConvert works and our privacy details. Keep your original files and check a converted file before you replace anything.

Frequently asked questions

As keys that start with @_, so <book id="7"> becomes {"book": {"@_id": 7}}. When an element has attributes and text, the text goes under #text. Converting the JSON back to XML turns these keys back into attributes.

When it's repeated under the same parent. Two or more <item> elements give an array, while a single <item> gives an object. Code that reads the JSON should accept both if the count can change.

The converter checks the XML first and tells you what's wrong and where, such as a closing tag that doesn't match, with its line and column, so you can fix it in your editor.

No. Every live tool on JustYourConvert opens and converts your files inside your browser, on your own device. Nothing is sent to our servers, and the result is saved straight from your browser.

Yes. Every tool is free, with no sign-up, no watermark and no daily limit. Clearly labeled ads keep it that way.

Only your device's memory. Because the work happens in your browser, very large files can be slow on phones and older computers. Each tool says its practical limit under the drop area.