Code & Data

Convert XML to JSON

Paste XML and get JSON. Attributes become @-prefixed keys, repeated elements become arrays, and CDATA comes through as text.

or paste your own — nothing is uploaded.

Indentation

XML has no arrays. An element appearing once becomes a value and twice becomes a list, which means the shape of the output depends on the data — worth knowing if something downstream expects an array.

JSON

Paste XML above and the JSON appears here.

  • Runs in your browser
  • No account required
  • Free to use

How it works

01

The array problem, and how it is resolved

XML has no arrays — a list is the same element name appearing several times. So whether a single `<item>` means one value or a one-element list is genuinely ambiguous, and no converter can know. The rule here is the common one: one occurrence becomes a value, two or more become an array. It is worth understanding, because it means the shape of the JSON depends on the data rather than on the schema.

02

Attributes are prefixed, not merged

An attribute becomes a key beginning `@`, so `<a id="1">` gives `{"@id": "1"}`. Merging attributes and child elements into the same namespace would silently collide when an element has both an `id` attribute and an `<id>` child.

03

A leaf is just its text

An element with no attributes and no element children becomes its text content rather than an object wrapping it. That is the shape people expect, and it keeps simple documents simple.

What it does

Attributes optional

One checkbox drops them entirely, for when you want the data and not the markup metadata.

Formatted or minified output

Two spaces, four, or no whitespace at all.

Parse errors with a line

Malformed XML is reported the same way the formatter reports it, rather than producing partial JSON.

Runs in your browser

No upload. What you paste in is never sent anywhere.

Practical advice

Getting a better result

  • Check the output shape before relying on it: an element that appears once in your sample and twice in production will change from a value to an array.
  • If you only need the data, turn attributes off — it usually halves the size of the result.
  • Mixed content, where an element holds both text and child elements, has no clean JSON equivalent. The text is kept under a #text key, but that shape is awkward by nature.

Questions

Things people ask

Why did my single element not become an array?

Because XML gives no way to tell a one-item list from a single value — both are one element. The convention used here is that one occurrence is a value and two or more form an array. If your consumer always expects an array, it is worth normalising after conversion.

What happens to attributes?

Each becomes a key prefixed with @, so they cannot collide with a child element of the same name. There is a checkbox to drop them entirely.

Who builds these

Free tools by day. Websites that earn their keep by trade.

KuConvert is built by KUDUY, a web design and development agency. From custom WordPress builds to SEO and e-commerce, everything they do is engineered to bring you more qualified traffic and turn it into revenue.

  • Fixed scope, no surprise invoices

    Most sites ship in four to eight weeks with the scope and the price agreed up front.

  • SEO from day one

    Search is designed into the build — structure, schema and Core Web Vitals — not retrofitted.

  • A team, not a ticket queue

    A project manager, a designer and a developer you can actually reach.

Need your whole site to load this fast?

Images are usually the heaviest thing on a page and the easiest win. KUDUY works on site speed, image delivery and Core Web Vitals for teams who would rather not do it by hand.

This tool runs entirely in your browser. Your files are never uploaded.