XML ↔ JSON Converter

Attributes map to @_name keys, repeated sibling tags become arrays. No namespaces or DTD validation — a practical subset, not a full XML 1.0 parser. Cmd/Ctrl+Enter saves the current input to history.

Advertisement

Convert XML to JSON, or the reverse. Attributes become @_-prefixed keys, text alongside attributes or children is stored under #text, and repeated sibling tags become arrays — the same convention used by the popular fast-xml-parser library, so the output shape is predictable if you've used it before.

Frequently asked questions

How are XML attributes represented in the JSON output?
As keys prefixed with @_ — an attribute id="5" on an element becomes "@_id": "5" in that element's JSON object. This matches the convention used by the popular fast-xml-parser library, so the shape is familiar if you've worked with that.
What happens to text content when an element also has attributes or children?
It's stored under a "#text" key alongside the attributes/children, rather than being dropped — an element with no attributes and no child elements collapses to a plain string instead.
Do repeated sibling tags become an array?
Yes — if an element has more than one child with the same tag name, those children become a JSON array; a single occurrence stays a plain object.
Converting JSON back to XML — does it need a specific shape?
Yes — the top-level JSON object must have exactly one root key, since XML requires a single root element; multiple top-level keys are rejected with an explicit error.
Is my data uploaded anywhere?
No. Conversion happens locally in your browser tab — nothing is sent to a server.

Read the full guide for this tool →

Advertisement