DuckyTools
Home Convert XML to JSON

XML to JSON Convert

Parse XML into a JSON structure, attributes included.

XML to JSON is a free online tool that parse XML into a JSON structure, attributes included. It runs entirely in your web browser using DOMParser, so files are processed on your own device and never uploaded to a server. There is no sign-up, no file size limit imposed by the site, no watermark and no paid tier.

Price
Free — no account, no quota, no watermark
Category
Convert
Where it runs
In your browser, on your device
Files uploaded
None
Technology
DOMParser
Settings
None — it just works
Works offline
Yes, after the first visit

About XML to JSON

This uses the browser's own XML parser, so it accepts exactly what a browser accepts and reports parse errors the same way. The structural decision every converter has to make is what to do with attributes, since JSON has no equivalent concept: here they become keys prefixed with `@`, which is the convention used by most established converters and keeps them distinguishable from child elements.

How to use it

  1. Paste the text you want to run through xml to json.
  2. There is nothing to configure — the result updates as you type.

Under the hood

Runs onDOMParser — parses the markup

Questions

How are attributes represented?

As keys prefixed with `@` on the same object as the element's children, so `<user id="7">` yields `{"@id": "7", ...}`. That keeps them from colliding with a child element also named `id`.

Why is a single child element not an array?

Because XML gives no way to tell "a list that happens to have one item" from "a single item". Without a schema, one child is one object. Handle both shapes in your consuming code.

What does XML to JSON use to do the work?

DOMParser parses the markup — all of it running inside this page rather than on a server.