Skip to content

XML to JSON

Convert XML documents and feeds into JSON.

How to use the XML to JSON

Three steps, all in your browser.

  1. 1

    Paste your input

    Type or paste your code or data. Press Sample to try an example.

  2. 2

    Check the options

    Adjust the options if you need to. The conversion updates instantly.

  3. 3

    Copy the result

    Copy the output in one click. Nothing is saved or sent anywhere.

XML to JSON: what to know

XML to JSON parses XML with fast-xml-parser and outputs formatted JSON, so you can work with feeds, SOAP responses or config files in JavaScript and other JSON-first tools. Elements become keys, text becomes values and repeated sibling elements become arrays.

XML has things JSON doesn't, so a few conventions apply. Attributes are kept as keys with an @_ prefix, so <price currency="EUR">9</price> keeps both the attribute and the text. An element that appears once becomes a single value while one that repeats becomes an array; code that reads the JSON should be ready for both shapes.

Malformed XML is reported with the problem rather than converted partly. Comments and processing instructions aren't part of the data and are left out.

Popular uses

  • Reading RSS and Atom feeds in JavaScript
  • Converting SOAP responses for a JSON API
  • Migrating XML config to JSON
  • Exploring the structure of an unfamiliar XML document

Tips for the best result

  • Numeric-looking text such as 007 stays as written when it matters; check IDs before relying on types.
  • If you always need an array for a repeated element, normalize it in your code: single items aren't wrapped.
  • Format the XML first with the XML formatter if you need to see its structure.

Read how JustYourDev works and our privacy details. Code, data and files you use here are processed in your browser and are never sent to our server.

Frequently asked questions

Attributes become keys with a prefix so they don't clash with child elements of the same name. For example <item id="7"> gives a key such as "@_id": "7" next to the element's children.

A single child element converts to a value and repeated children convert to an array, because XML doesn't say which is which. If your code needs an array every time, check for both shapes.

No. Every tool runs in your browser, so your code, tokens, keys and files are processed on your device and are not sent to our server or stored. Reloading or closing the page clears them.

Yes. Every tool is free with no sign-up and no limits on use. Clearly labeled ads keep it that way.

Yes. The tools work in any modern browser on phones, tablets and computers, though large files and long code are easier to handle on a computer.