Toolstia / XML to JSON converter

XML to JSON converter

Paste XML and get clean JSON back. Attributes, repeated elements, text and CDATA are all handled, and you can choose how attributes are named.

Repeated tags become an array. Attributes get the prefix you choose, and text that sits beside child elements or attributes goes under the text key. Comments and the XML declaration are dropped.

How it works

  1. Paste your XML.
  2. Set the attribute prefix and the key used for text, and tick number conversion if you want real numbers.
  3. Copy the JSON.

How elements map

An element with only text becomes a string, an empty element becomes null, and an element with children becomes an object. Tags that repeat become an array.

Attributes and text

Attributes get a prefix, @ by default, so they cannot clash with child tags. When an element has attributes or children and text, the text goes under the text key.

Numbers and booleans

XML has no types, so everything is text unless you turn on conversion, which changes values like 12, 3.5, true and false but keeps text like 007 as it is.

What is left out

Comments, the XML declaration and processing instructions are dropped. Entities such as & and CDATA blocks are decoded.

Questions

Is the XML checked?

Yes. Mismatched or unclosed tags, a second root element and unquoted attributes are reported as errors.

What about namespaces?

Prefixed names such as ns:item are kept exactly as written.

Is my XML uploaded?

Everything happens in your browser, and nothing you enter is sent anywhere.