XML to JSON Converter

Convert XML to JSON: elements become objects, repeated elements become arrays, and attributes are kept under @attributes. Parsed in your browser.

Work in your browser

Local and private

Well-formed XML only. Attributes are preserved under @attributes and repeated elements become arrays.

How to use XML to JSON Converter

Three simple steps, with your content kept on your device.

01

Paste XML

Add a well-formed XML document with elements, attributes, and text.

02

Convert

The XML tree is parsed locally and converted to an indented JSON structure.

03

Copy or download

Copy the JSON or download it as a .json file.

Built for useful work

Fast, focused, and made to be clear on every screen.

Attributes preserved

Element attributes are kept under an @attributes key so nothing is lost.

Arrays for repeats

Repeated elements become JSON arrays automatically.

100% local

Parsing happens in your browser. Your XML never leaves the page.

Why convert XML to JSON

XML and JSON are the two most common structured data formats on the web, and they appear in different layers of the same systems. XML is often used for documents, feeds, and legacy APIs, while JSON is the default for modern web APIs and JavaScript applications.

An XML to JSON converter bridges that gap: it works as an xml to json parser that turns a well-formed XML document into a JSON structure consumable by a REST client, a database import, or a front-end application without writing custom parsing code.

How the converter maps XML

To convert XML online, paste your document into the editor and run the converter. Elements become JSON objects, repeated elements become arrays, and text content is preserved, producing a readable indented JSON representation of the whole document.

Attributes are collected under an @attributes key on each element, so nothing is lost in the conversion. The result can be copied with one click or downloaded as a .json file.

Elements, attributes, and text

The converter follows a predictable mapping. An element with only text becomes a string value; an element with children becomes an object whose keys are the child element names; an element with attributes gains an @attributes object.

Mixed content — text interleaved with child elements — is preserved through a #text key, and repeated child elements are grouped into arrays automatically. This keeps the JSON faithful to the original XML tree.

Namespaces and edge cases

Basic namespace prefixes are preserved as part of the element name, so ns:item becomes a JSON key of 'ns:item'. Full namespace resolution is not performed, which matches how many lightweight converters behave.

The input must be well-formed XML: matching tags, quoted attributes, and no misplaced characters. Invalid XML is reported with a clear message so you can correct the document and convert again.

Local and private conversion

XML documents can contain sensitive data such as customer records, financial feeds, or internal system exports. This tool parses everything locally in your browser, so your XML never leaves your device.

There is no upload, no queue, and no account. The converter works offline once loaded, and large documents are processed in a single pass with a clear depth limit to protect your browser from maliciously deep nesting.

Related structured-data tools

JSON is often the destination for these conversions. The JSON Validator checks that the resulting structure is syntactically correct, and the JSON Formatter makes it readable.

For the reverse direction, the TOML to JSON Converter handles configuration files, and the YAML Validator checks YAML documents. Together these tools cover the common data formats developers move between every day.

XML to JSON in practice

Real-world conversions come from many sources: SOAP responses, RSS and Atom feeds, sitemap documents, legacy database exports, and configuration files that predate JSON. In every case the same predictable mapping applies, so the JSON output matches the structure of the original document.

Developers commonly convert a small XML sample first to understand the mapping, then convert the full document once the structure is clear. The tool makes both steps fast because the result can be copied directly into code or tests.

The JSON produced by the converter is standard, so it can be validated with the JSON Validator, formatted with the JSON Formatter, or sent directly to any API or application that consumes JSON.

Keeping the converter local also means you can work with proprietary XML feeds and internal exports without routing them through an external service. Paste the document, review the generated structure, and keep the data entirely on your machine.

A quick local conversion also helps when writing tests: generate the expected JSON once, inspect it, and use it as the fixture your test asserts against.

Frequently asked questions

How are XML attributes converted?

Attributes of an element are collected under an @attributes object, so <user id="1"> becomes {"@attributes": {"id": "1"}, "#text": ...} (or the element's children).

What happens to repeated elements?

Elements with the same name are grouped into arrays, for example multiple <user> children become a "user": [...] array.

Does this tool support namespaces?

Basic namespace prefixes are preserved as part of the element name (for example ns:item). Full namespace resolution is not performed.