XML ↔ JSON Converter

Convert XML to JSON or JSON to XML instantly. Handles attributes, text content, and repeated elements. 100% client-side.

Last reviewed: April 2026

New to this tool? Click here for instructions

XML Input
JSON Output
Paste XML or JSON above to convert.

How to Use the XML to JSON Converter

To use the XML to JSON converter, follow these steps:

1. Choose the direction of conversion (XML to JSON or JSON to XML) using the chips above the input area.

2. Paste your XML or JSON data into the input area on the left.

3. View the converted output on the right, which updates as you type.

4. Copy or download the result as a .json or .xml file.

When to Use the Tool in Real Workflows

Use the XML to JSON converter when you need to convert data between these two formats for various purposes such as SOAP to REST migration, RSS/Atom feed parsing, configuration files, and data transformation pipelines.

How It Works

The converter uses the BadgerFish-inspired convention to map XML to JSON. This means that XML attributes become JSON properties prefixed with @, mixed content uses #text for the text portion, repeated sibling elements are grouped into a JSON array, and text-only elements with no attributes become plain string values. Nested elements become nested JSON objects.

Tips, Edge Cases, or Limitations

The converter handles attributes, text content, repeated elements, and nested structures effectively. However, it cannot perfectly preserve all XML features. XML namespaces, processing instructions, CDATA sections, and XML comments are not preserved in the JSON output. The root element name is preserved as the top-level key in the JSON object.

When converting JSON back to XML, properties with @ prefix become attributes, and arrays generate repeated elements with the same tag name. The root element is named "root" by default if the JSON starts with an object.

Frequently Asked Questions

XML attributes become JSON properties prefixed with @.
Repeated sibling elements are grouped into a JSON array.
No, the conversion is done client-side, and no data is sent to a server.
#text represents the text portion of mixed content in the XML.
Yes, the converter can handle JSON to XML conversion.