EN
My tools

XML to JSON Converter

Convert XML to JSON with your choice of attribute and text conventions, arrays for repeated elements, type coercion and namespace stripping. Errors by line.

Otherwise only repeated elements become arrays, so the shape can change when an element appears once.
Text such as 44.95 becomes a number. Values with a leading zero (01234) stay text.
soap:Body becomes Body; xmlns declarations are dropped.
JSON

Well-formed XML · 11 elements · 5 attributes · root <catalog>

Repeated elements become arrays; an element that appears once stays a single value. Tick "Always use arrays" for a stable shape.

My tools →
Advertisement

XML and JSON describe the same kind of tree, but XML has things JSON lacks — attributes, mixed text, comments, namespaces — so every converter has to pick a convention. This one lets you choose how attributes and text are written, whether repeated elements become arrays, and whether "44.95" and "true" turn into a number and a boolean. The XML is checked for well-formedness first, and any error is reported with its line and column.

How to use this tool

  1. Paste the XML (an RSS feed, a SOAP response, a config file, an SVG…).
  2. Choose how attributes appear: @id, -id, _id, an _attributes object, or not at all.
  3. Tick Always use arrays if your code expects the same shape every time.
  4. Turn on number and boolean conversion or namespace stripping if you need them, then copy the JSON.

Formula

element → key · attributes → "@name" · text → value or "#text" · repeated element → array

An element with only text becomes a string; one with attributes or children becomes an object, and its text goes under the text key. Entity and character references are decoded, CDATA is kept as text, and line breaks inside attribute values become spaces, as the XML specification requires. Processing instructions and the DOCTYPE are not included.

Example

In the sample catalog the two <book> elements become an array under book. The first is {"@id": "bk101", "@lang": "en", "author": "Gambardella, Matthew", "title": "XML Developer's Guide", "price": {"@currency": "USD", "#text": "44.95"}, "available": "true"} — &apos; is decoded to an apostrophe, and with number conversion on, the price text becomes 44.95 and available becomes true.

Frequently asked questions

Why is an element sometimes an array and sometimes not?

By default only repeated elements become arrays. If a feed sometimes has one item and sometimes several, tick Always use arrays so your code sees a list every time.

Is the conversion reversible?

Not exactly. Comments, processing instructions and the order of mixed text and elements are lost, which is true of any XML-to-JSON convention.

Why does &nbsp; give an error?

XML only predefines &amp; &lt; &gt; &quot; and &apos;. HTML names such as &nbsp; must be declared in a DOCTYPE or written as a number, e.g. &#160;.

Sources

Last updated:

Cite or embed this tool
APA

kakaoCalc. (2026, November 8). XML to JSON Converter. https://kakao.mobile/tools/xml-to-json-converter/

MLA

“XML to JSON Converter.” kakaoCalc, 8 Nov. 2026, kakao.mobile/tools/xml-to-json-converter/.

Paste this code into your page. The widget runs in your visitors' browsers, shows no ads and keeps a link back to this page. Embedding terms

Advertisement