LazyTools

🔒 Every tool runs in your browser — the files and values you enter are never uploaded to any server. How it works

🗂️ XML to JSON Converter

Paste XML and get JSON — attributes keep an @ prefix, repeated sibling elements become arrays, and parse errors are reported plainly.

✗ DOMParser is not defined

Rate this tool:
Anonymous — no account, no identifier

How the xml to json converter works

Parsing uses the browser’s native DOMParser — the same engine that renders XML in web pages — so well-formedness rules are enforced exactly. The mapping convention: element attributes become "@name" keys, text content of mixed elements becomes "#text", and repeated sibling elements (like the two <book> entries in the sample) collapse into a JSON array.

XML-to-JSON has no single canonical mapping — attributes and repeated elements force conventions. Ours matches the common "@/#text" style used by most tooling, and keeps values typed (the year 1965 arrives as a number). Feeds (RSS), SOAP payloads and legacy exports are the usual customers.

Frequently asked questions

How are attributes represented?

As keys prefixed with @: <book id="1"> becomes {"@id": 1, ...} — the widely used convention that keeps attributes distinguishable from child elements.

Why is one <item> an object but two <item>s an array?

JSON has no repeated keys, so single children map to objects and repeated siblings to arrays. Code consuming varying feeds should handle both shapes — or normalize afterward.

Why does my XML fail to parse?

DOMParser enforces well-formedness: every tag closed, one root element, & escaped as &amp;. The error message quotes the parser’s reason, usually with a line reference.

Are namespaces supported?

Tags keep their prefixed names (ns:tag) as-is — namespace semantics beyond naming are not interpreted, which suits most conversion needs.

Is my XML kept local?

Yes — parsing happens in your browser with nothing transmitted.

Related file converters

From the blog