All processing happens in your browser. Your file is never uploaded to any server.
Paste XML
Upload File

Click to select or drag & drop a .xml file

All conversion runs in your browser. Your data is never uploaded to any server.

XML to JSON

This free XML to JSON converter turns XML into JSON entirely in your browser. Paste your markup, upload an .xml file, or drag one in — then read the result and download it. Nothing leaves your device, and there is no sign-up.

There is no single official way to map XML onto JSON. Attributes, namespaces, repeated elements and mixed text can each be mapped several ways, and most converters pick defaults without telling you which. This page states its rules up front and lets you change each one, so the JSON you get is the JSON you expected.

How to use this XML to JSON converter

Conversion rules — exactly what this page does

Attributes

Every attribute becomes a key on its element object, prefixed with @ by default, so <book id="b1"> yields "@id": "b1". Switch to _ for "_id", or to No prefix for a bare "id". Use a prefix: with No prefix, an attribute whose name matches a child element name is overwritten by that element.

Namespaces

Attribute names follow the same setting. The default namespace (a plain xmlns="…") has no prefix, so its elements are named by local name under all three settings.

Repeated elements — object or array

Text

Empty elements and values

What is ignored

Comments, processing instructions and the DOCTYPE are skipped. XML recognises only five built-in entities — &amp;, &lt;, &gt;, &apos;, &quot;; an HTML entity such as &nbsp; is invalid XML and is reported as a parse error with its line and column rather than silently patched.

What this tool supports

Limits — read this before pasting something huge

Privacy

Uploaded files are read with the browser's own file reader and never leave your device. There is no upload endpoint on this page, no account, and no stored history. You can disconnect from the internet after the page loads and it will still work.

FAQ

Is this XML to JSON converter free?

Yes. It is free with no login and no usage limit, and all processing stays in your browser. For other formats see the JSON to CSV converter, the CSV to JSON converter, the JSON to Excel converter and the CSV to Excel converter.

Do I have to upload my XML file?

No. The file is read locally with the browser's file API and converted in the page. Nothing is uploaded, logged or stored.

How do I convert an XML file to JSON?

Drag the .xml file onto the drop area or pick Upload File and choose it. The converter reads the file, applies the settings you chose, and shows the JSON. Then press Download .json. The downloaded file name carries a timestamp, for example xml-to-json-20260919-234500.json.

Why is one element an object and a similar one an array?

That is the default Auto rule: two or more sibling elements with the same name become an array, a single one does not. If you want a stable shape, set Repeated elements to Always arrays.

How are attributes named in the JSON?

With a @ prefix by default, so id="b1" becomes @id. You can switch to a _ prefix or to no prefix. A prefix avoids collisions with child element names.

What happens to namespaces?

By default prefixes are stripped, so d:book becomes book. Choose Keep prefixes to retain them, or Full URI keys to write the complete namespace URI in the key.

Why does my XML fail with "error on line X"?

The document is not well-formed at that position — commonly an unclosed tag, a mismatched tag name, or an HTML entity like &nbsp; that XML does not define. The message quotes the line and column where the parser stopped so you can jump straight to it.

Can I get minified JSON instead of indented JSON?

Yes. Set Output to Minified for a single-line file, or leave it on Pretty for two-space indentation. Either way you can copy the result or download it.

Is there a file size limit?

No fixed one — the limit is your device's memory. Files above roughly 8 MB or 200,000 elements trigger a warning because browsers commonly struggle there, but the tool still attempts the conversion and reports any failure instead of returning a partial result.

Can I convert JSON back to XML?

Yes — use the JSON to XML converter. It mirrors this page's rules, so the same attribute prefix, the same namespace handling, and text held in #text all come back the other way. For other output shapes, see the JSON to CSV converter or the JSON to Excel converter.