b2KIT

XML to JSON Converter

Parse XML documents and convert them to equivalent JSON structure with attributes.

How to Use XML to JSON Converter

  1. 1

    Paste your XML

    Enter the XML data you want to convert to JSON.

  2. 2

    Convert instantly

    See the JSON output generated automatically from the XML.

  3. 3

    Copy the JSON

    Click copy to grab the converted JSON output.

Tested tool guide Developer and data tools Checked July 30, 2026

What XML to JSON Converter does, with a checked example

XML and JSON model documents differently, so conversion requires explicit conventions. This tool parses elements, text, repeated child elements, and attributes into a JavaScript object before serializing it as JSON. Attributes use an @_ prefix and mixed text uses #text so those values are not confused with child elements.

Worked example

A concrete input and expected output from the current implementation.

Input

<note id="7"><to>Bee</to><priority>high</priority></note>

Expected output

{
  "note": {
    "@_id": "7",
    "to": "Bee",
    "priority": "high"
  }
}

The id attribute is kept separately from child elements. Each child appears once, so its value is represented directly instead of as an array.

How the result is produced

1

Repeated elements become arrays

When siblings share a tag name, their converted values are collected in document order. A single child remains a scalar or object, which keeps common output compact.

2

This is a lightweight parser

Elements, attributes, comments, CDATA, common entities, and basic declarations are handled. Advanced namespace processing, DTD validation, and full XML Schema validation are outside its scope.

Good uses

  • Inspect a small configuration or export file in JSON form.
  • Prototype a mapping before writing production conversion code.
  • Turn a repeated XML list into data that is easier to browse.

Limits and checks

  • XML attributes are strings even when they look numeric or Boolean.
  • Mixed-content documents may require application-specific ordering rules.
  • Validate important source documents with a full XML parser before migration.

Common questions

Is there one official XML-to-JSON mapping?

No. XML has attributes, namespaces, mixed content, and ordering rules that do not map uniquely to JSON. Always document the convention used by a converter.

Why did one element become an array?

The same child tag appeared more than once under its parent. The array preserves every occurrence and its order.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools