XML to JSON

Convert XML documents into structured JSON online. Automatically maps XML attributes to `@_attribute` properties, groups repeated sibling elements into JSON arrays, and preserves text nodes.

Private • In-browser processing • Zero server uploads

Interactive workspace loading...

How to Use XML to JSON

1
Paste XML Data
Paste your XML markup or drop an `.xml` file into the input box.
2
Choose Indentation
Select your preferred JSON indentation (2 Spaces, 4 Spaces, or Minified).
3
Copy JSON
Copy the converted JSON object or download it as a `.json` file.

Key Features

Attribute Mapping
Uses standard `@_attributeName` conventions to retain all XML element attributes.
Array Grouping
Intelligently detects and groups identical sibling elements into clean JSON arrays.
Text Node Retention
Uses `#text` mapping for elements that possess both attributes and child character data.
Configurable Formatting
Output formatted with 2 spaces, 4 spaces, or compact minification for web services.

Common Use Cases

  • Transforming legacy SOAP API responses into lightweight JSON for mobile and frontend web apps.
  • Ingesting XML RSS and Atom news feeds into JavaScript modern frameworks (React, Vue, Svelte).
  • Converting XML sitemaps or catalog files into database-ready JSON records.
  • Migrating XML configuration files into modern JSON or NoSQL data stores.

Frequently Asked Questions

To prevent name collisions between child elements and tag attributes, attributes are prefixed with `@_` (for example, `<book id="1">` becomes `{ "book": { "@_id": "1" } }`).

When multiple sibling tags share the same name (such as multiple `<item>` tags inside `<catalog>`), the converter automatically collects them into a single JSON array (`[ ... ]`).

When an XML element contains both attributes and inner text (e.g. `<user role="admin">Alice</user>`), the text is assigned to a `#text` property: `{ "@_role": "admin", "#text": "Alice" }`.