XML to JSON

Convert XML documents into readable JSON, with attributes and repeated elements handled cleanly. Private and instant.

  • Free, no sign-up
  • Files stay on your device
  • Works on mobile
Loading tool…

XML to JSON converts XML documents into readable JSON. Elements become keys, repeated elements become arrays, and attributes are kept in a clearly marked form so no data is lost. It is the quickest way to work with an XML feed or config file in JavaScript or any modern tool that prefers JSON.

Developers use it for RSS feeds, sitemaps, invoice files and responses from older SOAP services. One thing to know: an element that appears once becomes a single value, while the same element appearing twice becomes an array, so check how your code handles lists that may contain only one item.

How to use XML to JSON

  1. Paste XML or choose or drop an .xml file into the main area.
  2. Review the options in the settings panel on the right, such as how attributes are prefixed.
  3. Press Convert to JSON.
  4. Copy the JSON or download it as a .json file.

Features

  • Parsing happens in your browser; feeds and invoices are not uploaded.
  • Attributes are preserved with a prefix so they don't collide with child elements.
  • Repeated elements become JSON arrays.
  • Malformed XML, such as unclosed tags, produces an error instead of partial output.
  • Comments and processing instructions are not carried into the JSON.

When to use it

  • Reading an RSS feed in a JavaScript project that expects JSON.
  • Inspecting a website's XML sitemap as structured JSON.
  • Converting an e-invoice XML file to JSON for a reporting script.

Frequently asked questions

How are XML attributes shown?

They appear as keys with a prefix, such as @id, so you can tell them apart from child elements.

Why is one field an array and another a single value?

Elements that repeat become arrays; elements that appear once stay as single values. Lists with one item will therefore not be arrays.

Can it handle namespaces?

Namespace prefixes are kept as part of the element names, for example ns:item.

Why do I get an error?

The XML is not well-formed. Look for unclosed tags, unescaped & characters, or more than one root element.

Is the JSON output formatted?

Yes. It is indented for readability. Paste it into JSON Formatter if you want to minify it.