XML → JSON Converter

Turn XML documents into structured JSON.

Your data is processed entirely in your browser and is never uploaded.

Tool workspace

INPUT XML

Drag & drop file here or browse

Status: Empty0 chars

Options

Keeps repeated elements as arrays. Turn off to collapse to the last value.

Output indentation
Ready, paste to start
OUTPUT JSON
Output: Empty0 chars
HOW IT WORKS

Convert XML to JSON in three steps

Paste or upload

Drop in any XML: RSS, SVG, configs, or API responses.

Configure output

Choose whether to include attributes, preserve arrays, and set indentation.

Convert & export

Click Convert, then copy or download the resulting JSON. All offline.

Docs · XML → JSON

Parsing XML into JSON

XML → JSON parses an XML document and converts it to a JSON representation. Attributes become properties prefixed with `@`; text content becomes a `#text` property (or is merged when possible). Repeated elements are preserved as arrays. The parser handles comments, CDATA, and basic namespaces, but keeps the output clean and readable. All processing happens locally.

Common issues & tips

Missing closing tag

If your XML is missing a closing tag, the parser will throw an error. Check the line and column of the error message to fix it.

<root><name>Ada</root>
Attributes as @

Attributes are stored as `@attributeName`. For example, `<item id="1"/>` becomes `{ "@id": "1" }`. Turn off attribute inclusion if you only need the element content.

Text content

Text content becomes `#text` when there are attributes or child elements; otherwise, it becomes a direct string value. This keeps the JSON clean and type‑friendly.

CDATA

CDATA sections are treated as normal text content and are included. They are not wrapped in a special property.

Try these

Simple XML
<root><name>Ada Lovelace</name></root>

A basic XML document with a single root and element.

With attributes
<root><item id="1">First</item></root>

Attributes are preserved with @ prefix.

Nested and repeated
<root><user><name>Ada</name></user><user><name>Alan</name></user></root>

Repeated elements become arrays.

pair this withReverse it → JSON → XML·Format the result → JSON Formatter·Validate the result → JSON Validator

FAQ

Frequently asked questions

Is my XML uploaded anywhere?

No. Conversion runs entirely in your browser (in a background worker). Your data never leaves your machine.

How are XML attributes handled?

Attributes are prefixed with @ in the JSON output (e.g., "@id": "1"). You can toggle them on/off.

What about CDATA and comments?

CDATA is treated as text. Comments, processing instructions, and DOCTYPE declarations are skipped for clean output.

Why are arrays sometimes single objects?

If "Preserve arrays" is off, a single child becomes an object. Turn it on to always get arrays for repeated tags.