Free Tool · No signup required

XML to JSON Converter

Convert XML elements and attributes to clean JSON — runs in your browser

XML Input
JSON Output

Paste into the left panel, upload a file, or click Sample to try it out · use Swap to reverse the conversion

Working with a REST API that needs JSON but your data source outputs XML? Paste the XML and get clean, well-structured JSON back instantly. Attributes are mapped to @ keys, text nodes to # text, and all nested elements become child objects — fully configurable.

How to Convert XML to JSON

Paste XML and download JSON in seconds — browser-only, no data sent anywhere.

1
Step 1

Paste or upload your XML

Enter an XML document in the input panel or upload a .xml file. The converter checks for well-formedness before parsing.

2
Step 2

Automatic JSON mapping

Elements map to JSON object keys, attributes map to @ prefixed keys, and repeated elements become arrays. Text content maps to a # text key when mixed content is present.

3
Step 3

Copy or download

Click Copy or Download as .json. Use the result directly in your JavaScript, Python, or any language that consumes JSON.

Features

Runs entirely in your browser using the native DOMParser API

Live conversion updates as you type — no submit button needed

XML attributes are mapped to @key entries in the JSON object

Text content is preserved as #text when mixed with child elements

Repeated sibling elements with the same tag are automatically grouped into a JSON array

Handles deeply nested XML structures of arbitrary depth

Upload a .xml file and download as .json

Swap button converts JSON back to XML in the same tool

Free, no sign-up, no file size limits

Related Tools

Frequently Asked Questions

Does my XML get uploaded to a server?

No. Parsing uses the browser's built-in DOMParser API — entirely local. Your data never leaves your device.

How are XML attributes represented in the JSON output?

Attributes are mapped to keys prefixed with @. An element with an id attribute becomes a JSON object with an @id key. This convention is reversible — JSON to XML uses the same @ prefix to produce attributes.

What happens when the same tag appears multiple times?

Repeated sibling elements with the same tag name are automatically grouped into a JSON array. Three book elements inside a library element become an array of three objects under the book key.

How is text content handled?

If an element has only text and no child elements, it maps directly to a string value. If it has both, the text is stored under a #text key alongside the child keys.

Can I convert JSON back to XML in the same tool?

Yes. Click the Swap button — the tool handles both XML to JSON and JSON to XML.

What causes a parse error?

The most common causes are: missing closing tags, mismatched tag names, unescaped ampersands, or a malformed XML declaration. The browser parser will indicate the error location.