Category: Developer tools

XML to JSON Converter

System ideaMissing a tool?

Convert pasted XML text to JSON with a fixed attribute, text and array mapping

Paste XML and read the JSON in your browser. Attributes map to @attributes, repeated tags become arrays, pick 2 or 4 space indent, copy or download converted.json.

Paste XML to convert it to JSON.

JSON
The result will appear here.

Everything on this page is processed in your browser. Nothing is uploaded.

What this tool does

This XML to JSON converter parses the XML you paste with the browser's DOMParser using application/xml, then builds JSON with a fixed mapping. The JSON root key is the XML document element tag name. Element attributes go into an @attributes object. When an element also has attributes or child elements, its direct text becomes #text, while a text-only element is emitted as a plain JSON string. Repeated child elements with the same name are collected into an array. You can switch the JSON indentation between two and four spaces, and the result is regenerated whenever the XML text or the indentation changes, alongside a status message with the number of parsed elements. Copy the JSON or download it as converted.json. If the browser parser returns a parsererror, the tool shows an invalid XML message instead of emitting JSON. The conversion runs one way only: there is no JSON-to-XML direction, no XML Schema, DTD or namespace-aware validation, no custom mapping rules, and no XPath, XSLT, formatting, minification or querying. Input is pasted text, so there is no file picker, drag-and-drop, batch conversion or folder intake, and very large XML is limited by browser memory and DOMParser behavior. Comments, processing instructions, CDATA boundaries and namespace prefixes are not guaranteed to round-trip as separate JSON structures. The pasted XML and the generated JSON stay in the browser and are not uploaded to LocalTools.

How to use it

  1. Paste XML into the text area and watch the JSON and the parsed element count update as you type.
  2. Switch between two and four space indentation, and check the mapping: @attributes for attributes, #text for mixed content, arrays for repeated tags.
  3. Copy the JSON or download converted.json; reverse JSON-to-XML, file upload, batch runs and schema validation are out of scope.

Privacy

This tool runs entirely in your browser. Your input is never uploaded, stored or shared — closing the tab removes it.

Frequently asked questions

Why convert XML to JSON?
JSON is easier to consume in JavaScript and most modern APIs. This tool gives you a predictable JSON shape from pasted XML without installing anything.
Is this XML to JSON converter free?
Yes. It is a free browser-based converter with no account, no quota and no upload step.
Are XML attributes preserved?
Yes. Attributes are placed in an @attributes object. If the element also has attributes or children, its direct text becomes #text; a text-only element becomes a JSON string.
Is it safe to paste sensitive XML into this XML to json converter online?
Parsing happens in your browser with DOMParser. The pasted XML and the generated JSON are never uploaded to LocalTools, and the download comes from an in-page data URL.
Can we convert XML to JSON in Python?
You can, with libraries such as xmltodict, but this page is not a code generator. It only converts the XML you paste here into JSON in the browser.