Free tools, no sign-up — everything runs in your browser.
ToolHub 1000Free online tools

XML to JSON Guide: Elements, Arrays and Scalars

Learn how element nesting maps to objects, repeated elements map to arrays, and text maps to values.

What is the XML to JSON Converter?

This tool parses XML with a small parser written for this page, without relying on a browser XML parser, so the same logic can run in plain JavaScript environments too. Elements become objects, repeated child elements become arrays, and text values are converted to numbers or booleans when they clearly look like one, otherwise they stay as text. Element attributes are not preserved, and comments and processing instructions are skipped. Mismatched tags are reported as an error instead of producing a partial result.

How to use it

  1. Paste your XML into the box.
  2. Click Convert to JSON.
  3. Copy the JSON result.

Worked example

For the sample, the result is JSON with a data object containing a user object (name Ava, age 28 as a number) and a tags array with dev and js.

Why do repeated elements become an array?

Because a single object key can only hold one value, so the second element with the same name forces the value to become a list.

Frequently asked questions

Are attributes kept?

No. This small parser reads elements and text only, so attributes are skipped.

Why is age a number, not text?

Because text that looks exactly like a number is converted to a number, and true and false become booleans. Other text stays as a string.

Try the XML to JSON Converter free · All guides