How to Convert XML to JSON

Convert XML data to JSON format instantly. Handles attributes, namespaces, and nested elements. Free browser-based converter with formatting options.

Open XML Formatter →

Step-by-Step Guide

1

Paste your XML

Copy your XML data — an API response, config file, SOAP payload, or RSS feed — and paste it into the input area. The tool accepts any well-formed XML document.

2

Choose conversion options

Select how to handle XML attributes (as properties, prefixed with @, or ignored), text content naming, and array detection. These options control how the XML structure maps to JSON.

3

Convert to JSON

Click convert to transform XML into clean, properly structured JSON. Nested elements become nested objects, repeated elements become arrays, and attributes are mapped according to your settings.

4

Copy or download

Copy the formatted JSON to your clipboard or download as a .json file. The output is valid JSON ready to use in your JavaScript, Python, or any application that consumes JSON data.

Try It Now — Free

No signup, no download. Runs entirely in your browser.

Open XML Formatter

Frequently Asked Questions

How are XML attributes handled?
By default, attributes are converted to JSON properties prefixed with @. For example, becomes {"user": {"@id": "1"}}. You can change the prefix or flatten attributes into regular properties.
What happens with repeated XML elements?
Repeated sibling elements with the same name are automatically converted to JSON arrays. For example, multiple elements become a JSON array of item objects.
Can it handle CDATA and namespaces?
Yes. CDATA sections are extracted as plain text values. XML namespaces can be preserved as prefixed property names or stripped for cleaner output, depending on your settings.
Related Reference

JavaScript Cheat Sheet

View Cheat Sheet →

More Guides