Free XML to JSON Converter

Convert XML documents into clean JSON in one click. Attributes, repeated elements (as arrays), text content, and CDATA are all mapped sensibly — perfect for dragging legacy XML APIs into modern JSON workflows.

JSON output


    
Private by design. This tool runs 100% in your browser — your code is never uploaded to any server.

How to Use the XML to JSON

  1. Paste your XML document into the input box.
  2. Choose how attributes should appear (@attr or _attributes).
  3. Click Convert to JSON — the JSON appears instantly.
  4. Copy or download the result.

Features

Conversion uses the browser’s native DOMParser, so entity decoding and well-formedness checking are rock solid. Attributes map to @-prefixed keys (or a grouped _attributes object), repeated sibling elements automatically become arrays, mixed text lands in #text keys, and CDATA content is preserved as text. Malformed XML is rejected with the parser’s message.

Benefits & Use Cases

Developers modernize SOAP and RSS integrations by converting responses to JSON for JavaScript processing; data engineers bridge XML exports into JSON pipelines; anyone comparing API formats converts samples in seconds. Local conversion keeps payload contents private.

Tips

If an element sometimes appears once and sometimes multiple times, expect an object versus array inconsistency — normalize in code with a helper like [].concat(x || []). For huge documents, convert in chunks to keep the browser responsive.

Frequently Asked Questions

How are XML attributes represented in JSON?

By default as @-prefixed keys alongside the element’s children (e.g. {"@id": "1", "title": "x"}). You can switch to a grouped _attributes object if you prefer attributes separated from child elements.

What happens to repeated elements?

Repeated siblings with the same tag name become JSON arrays automatically — appearing three times yields "item": [{…}, {…}, {…}].

How is text content handled?

An element with only text becomes a plain string value. Elements mixing text with child elements put the text in a #text key so nothing is lost.

Are comments and processing instructions kept?

Comments are dropped (JSON has no comment equivalent in data); processing instructions outside the document element are skipped. CDATA sections are preserved as their text content.

Is my XML uploaded anywhere?

No. Parsing and conversion run entirely in your browser — your data never leaves your device.

Related Tools