XML to JSON converter

Paste XML from a feed, API or config and get equivalent JSON. Attributes are kept, repeated elements turn into arrays, and numbers can be typed for you.

Loading the tool…

How to use it

  1. Paste XML or drop an .xml file.
  2. Choose the attribute prefix and whether numbers and booleans should be typed.
  3. Copy or download the JSON.

Private by design

The conversion runs as JavaScript in this tab. Your data is not uploaded, logged or stored. There is no account and no file-size paywall.

The mapping rules

An element with only text becomes a value: <city>London</city> gives "city": "London". Attributes become keys with a prefix, so <total currency="GBP">42.50</total> gives {"@currency": "GBP", "#text": 42.5}. When the same child element repeats, the values are collected into an array.

XML has no notion of a one-item array, so an element that appears once in one document and twice in another produces a value in the first case and an array in the second. Code that reads the JSON should handle both.

Questions

Is my file uploaded anywhere?

No. The file is read by JavaScript in this tab and never leaves your device. You can load the page, switch off Wi-Fi and it keeps working.

Are namespaces supported?

Yes. Prefixed names like g:price are kept as keys.

What happens to comments and processing instructions?

They are dropped; JSON has nowhere to put them.

Can I convert back?

Use the JSON to XML converter. Keys starting with the attribute prefix become attributes again.

Related tools