🌐 English

Home › Convert

Convert XML to JSON

Turn XML from APIs, RSS feeds or config files into JSON that's easier to work with.

Input
Output

🔒 Your files and data never go to a server — everything is processed on your device (in your browser).

How to use

  1. Open an XML file or paste it.
  2. Choose whether to include attributes, typed values and the indent.
  3. Download or copy the JSON.

Conversion rules

Element names become keys, attributes become keys prefixed with @ (@id), and text next to attributes or children goes under #text. Two or more children with the same name become an array, and an element with only text becomes that text.

API responses

Paste an XML API response and you get JSON you can follow like response.body.items.item.

When this is handy

Use it for public APIs, product feeds, RSS and older configuration files that only come as XML and need to be handled by modern tools. Instead of long runs of tags you get keys and values, which makes the structure easy to scan.

It is also a good way to see what a response looks like before you write any code. You learn in advance how deep you have to go to reach the value you want.

How to choose the options

If the document does not need attributes, turn the attribute option off and the result becomes much shorter. If important data sits in attributes such as id or type, keep it on.

With the number option on, 3 comes out as a number, but values like codes or reference numbers where a leading zero matters are safer left as text. Remember that an element appearing once becomes an object while one appearing several times becomes an array, and write the code that reads the result with that in mind.

FAQ

The shape differs with one item vs many.

XML has no “list” marker, so one element becomes an object and two or more become an array. Handle both in your code to be safe.

What about namespaces (a:b)?

The name is kept as is (a:b) as the key.

How do I find XML errors?

If the format is wrong, CCO tells you roughly which line.

Is my data sent to a server?

No. Everything is converted in your browser.

What happens to comments and processing instructions?

Comments are not content data and are not included in the result. Element text and attributes are what get converted.

What if text and child elements are mixed?

Text that sits next to attributes or children is stored under the #text key. An element with only text simply becomes that text as its value.

Can large XML files be converted?

As far as your device memory allows, files of tens of megabytes work. Because the file never leaves your device, there is no server size limit to fit under.