Xml to json

Xml to json - free online tool.

Enable JavaScript to use the interactive tool. The guide below explains how it works.

XML to JSON Converter

What it does

This tool converts an XML document into JSON. Paste XML on the left; a JSON representation appears on the right, using the compact structure of the xml-js library. Malformed XML is reported and produces no output.

Why someone uses it

Step-by-step instructions

  1. Paste your XML into the input (a sample <a x="1.234" y="It's"/> is pre-filled).
  2. Check there is no "Provided XML is not valid" message.
  3. Copy the JSON from the output.

Examples

Input: <a x="1.234" y="It's"/>

Output:

{
  "a": {
    "_attributes": {
      "x": "1.234",
      "y": "It's"
    }
  }
}

Understanding the results

The conversion uses a compact format with conventions you need to know when reading the JSON: attributes are grouped under _attributes, text inside an element appears under _text, CDATA under _cdata, and comments under _comment. Repeated sibling elements with the same name become an array, while a single element stays an object, so the type of a field can change depending on how many times it appears. All attribute values are strings, even numeric-looking ones such as "1.234"; convert them in your code if you need numbers.

FAQs

Common mistakes

Use cases

Related tools

All tools

Guides and articles