🔒 No upload — 100% in your browser

XML to JSON Converter

Paste XML and get clean JSON in one click — attributes, CDATA, namespaces and repeated elements are handled correctly. Nothing is uploaded, everything stays in your browser.

Paste your XML on the left to see the JSON here.

How to Convert XML to JSON

This XML to JSON converter turns any XML document into a clean, readable JSON object you can use in APIs, scripts or data pipelines. Paste your XML on the left — or open an .xml file directly from your computer — and element attributes become JSON keys, repeated elements are collected into arrays, and CDATA sections, entity references and self-closing tags are all handled correctly. Text-only elements become plain strings, empty elements become empty strings, and the root element's attributes and children become the top-level JSON keys. You can switch between 2 and 4 space indentation and optionally convert numeric and boolean text values to real JSON types so your data arrives ready to use. Everything runs in your browser: your data is never uploaded, and you can copy the JSON or download it as a .json file.

  1. Paste your XML on the left — or click Open .xml file to load a document from your computer. Load sample fills the editor with a realistic catalog example you can convert right away.
  2. The conversion runs automatically while you type or paste; the Convert button does the same on demand. Malformed input shows a clear inline error instead of broken output.
  3. Choose 2 or 4 spaces for the JSON indentation — the output re-renders immediately when you switch.
  4. Optional: enable Convert numbers & booleans so true, false, 249.90 or 1e5 become real JSON booleans and numbers instead of strings. Values with leading zeros or a bare decimal point stay strings.
  5. The JSON appears on the right, with a status line showing the root element and the output size in characters. Copy it to the clipboard or download it as converted.json.

Standards-aware conversion: text and attribute values are decoded following the XML 1.0 rules for entity and character references, while CDATA content stays 100% literal. Comments, processing instructions and whitespace-only text are removed during parsing, and the result is emitted with JSON.stringify, so the output is always valid JSON (RFC 8259). See the XML 1.0 specification and RFC 8259 for the underlying standards.

Frequently Asked Questions

Is my XML uploaded to a server?

No. The whole conversion runs in your browser: the XML is tokenized and parsed locally with JavaScript, and .xml files are read with the FileReader API. Nothing is transmitted, there is no account and no backend is involved.

How are attributes and repeated elements converted?

Attributes become JSON keys with an @ prefix (@id, @currency), so they can never collide with child element keys. Repeated sibling elements, for example several product tags, are collected into an array. Keys appear in document order.

Does it handle CDATA, entities and namespaces?

Yes. The standard XML entities and numeric character references are decoded in text and in attribute values. CDATA sections stay fully literal and are never decoded. Namespace prefixes such as ns:item or xmlns are preserved as plain names; the tool does not resolve namespaces.

What does the numbers and booleans option do?

When enabled, the text true or false becomes a real JSON boolean and numeric-looking text such as 249.90, 14 or 1e5 becomes a real number. Values with leading zeros (007) or a bare decimal point (.5) stay strings so no data is corrupted. Attribute values are converted the same way.

What happens to comments, whitespace and processing instructions?

Comments and processing instructions such as the XML declaration are removed, and whitespace-only text between elements is ignored, so the JSON contains only your data. The input must contain exactly one root element; its attributes and children become the top-level JSON keys, and the root name is shown in the status line.

More free tools

Free online utility tools. No signup. No tracking.

Impressum · Some links contain affiliate advertising