DeveloperKit

XML to JSON Converter

Convert XML to clean, structured JSON instantly. Free, private, and 100% in your browser.

Input XML

JSON Output

JSON output will appear here.

Convert XML to JSON Online

Many legacy systems, SOAP services, and feeds speak XML, while modern applications and JavaScript code work best with JSON. This converter turns XML into JSON using clear, widely used conventions, so the result is easy to work with in any language.

Features

  • Predictable mapping

    Elements become keys, repeated elements become arrays, and attributes become @-prefixed keys.

  • Type detection

    Optionally turn "42", "true", and "false" into real numbers and booleans, only when the conversion is lossless.

  • Round-trip friendly

    Uses the same conventions as our JSON to XML converter, so you can convert back and forth.

  • Strict validation

    Malformed XML is reported with the exact line and column before anything is converted.

  • CDATA and entities

    CDATA sections and entities such as & are decoded into plain text.

  • Private by design

    The conversion runs entirely in your browser. Your data is never uploaded.

XML to JSON Example

XML input
<book id="bk101">
  <title>Clean Code</title>
  <author>Robert C. Martin</author>
  <tag>programming</tag>
  <tag>craft</tag>
  <price currency="USD">32.5</price>
</book>
JSON output
{
  "book": {
    "@id": "bk101",
    "title": "Clean Code",
    "author": "Robert C. Martin",
    "tag": [
      "programming",
      "craft"
    ],
    "price": {
      "@currency": "USD",
      "#text": 32.5
    }
  }
}

The id attribute becomes @id, the two <tag> elements become an array, and because <price> has an attribute, its value is stored under #text as the number 32.5.

How to Convert XML to JSON

  1. Paste your XML into the input editor, or upload an .xml file.
  2. Choose the indentation and whether to detect numbers and booleans.
  3. The JSON output updates instantly as you type.
  4. Copy the JSON or download it as a .json file.

Frequently Asked Questions

How are XML attributes converted to JSON?

Attributes become keys prefixed with @. For example, <book id="bk101"> becomes {"book": {"@id": "bk101"}}. If an element has both attributes and text, the text is stored under a #text key.

How are repeated elements handled?

Elements with the same name inside one parent become a JSON array. A single element becomes a plain value. For example, two <tag> elements become "tag": ["a", "b"].

What does Detect numbers and booleans do?

XML has no data types, so everything is text. With this option on, values like 42 and true become JSON numbers and booleans. Values that would change, such as 007, 1.50, or very large IDs, stay strings so no information is lost.

What happens to comments and processing instructions?

Comments, processing instructions, and the XML declaration are not data, so they are left out of the JSON output.

Is my XML uploaded anywhere?

No. The converter runs entirely in your browser using JavaScript. Your XML never leaves your device.

  • JSON to XML

    Convert JSON to well-formed XML with custom root and item names, attributes, and indentation.

  • XML to YAML

    Convert XML documents and configs into clean, readable YAML.

  • XML to CSV

    Turn repeated XML records into a CSV table for Excel or Google Sheets, with automatic row detection.

  • XML to Base64

    Encode XML documents, SOAP messages, and SVG as Base64 or base64url.