🇬🇧EN

XML to JSON

Convert XML into JSON — in your browser, nothing uploaded.

✨ What do you want to try next?

You've finished this tool — here are a few you might find useful.

Explore 100+ free toolsPDF, Image, Text, Convert, Calculate and more — all free.View all tools →

About XML to JSON

This turns XML into JSON so you can work with legacy or enterprise data in a modern, code-friendly shape. When you're pulling from a SOAP API, an RSS feed, an XML config or an old export and the rest of your stack speaks JSON, this does the translation — paste the XML and get an indented JSON object back.

How it works

The XML is parsed with the browser's built-in DOM parser, then converted to JSON:

  • Elements become object properties keyed by tag name.
  • Attributes are preserved with an @ prefix (an attribute id becomes "@id").
  • Repeated child elements with the same tag name become a JSON array.
  • An element with only text and no attributes becomes a plain string; if it has attributes too, the text is stored under "#text".

If the XML is malformed, the parser reports an error rather than producing broken JSON.

Assumptions and behaviour

  • Attributes are prefixed with @ and text content of mixed nodes is stored as #text, a common convention that keeps attributes and elements distinguishable.
  • Repeated tags collapse into arrays; a tag appearing once is a single value, the same tag appearing multiple times becomes a list.
  • Whitespace-only text is trimmed, so indentation in the source doesn't clutter the output.
  • The root element name is kept as the top-level key.

Limitations

  • Round-tripping isn't guaranteed. A tag that appears once becomes a single object while the same tag appearing twice becomes an array, so converting back to XML may not reproduce the original exactly.
  • Mixed content is simplified. Elements that interleave text and child elements don't map neatly to JSON and may lose the text or its ordering.
  • Element order isn't preserved the way it is in XML — JSON object keys don't carry document order for differing tags.
  • Namespaces are flattened into the tag name as written; it doesn't resolve or separate XML namespaces.
  • Comments, processing instructions and CDATA nuances aren't specially represented.

Privacy

Conversion runs entirely in your browser. Your XML and the resulting JSON never leave your device.

Frequently asked questions

Is this XML to JSON converter free?

Yes — free, no sign-up, no limits, runs in your browser.

How are XML attributes represented?

Attributes are kept with an @ prefix — an attribute named id becomes "@id" in the JSON — so they stay distinct from child elements.

How are repeated elements handled?

Repeated child elements with the same tag name become a JSON array. A tag that appears once stays a single value.

What about an element that has both text and attributes?

Its text is stored under a "#text" key alongside the @-prefixed attributes. A text-only element with no attributes becomes a plain string.

Can I convert the JSON back to identical XML?

Not always. Because single vs repeated tags map to value vs array, and mixed content is simplified, a round trip may not reproduce the original XML exactly.

Does it handle XML namespaces?

Namespaces are flattened into the tag name as written; the tool doesn't resolve or separate them.

Is my data uploaded?

No. Conversion runs entirely in your browser; nothing is sent or stored.

Lakshay Kumar

Written by Lakshay Kumar(TechLakshay)

A QA Automation Engineer by trade, Lakshay's real passion is untangling complex problems into simple, working solutions — which is exactly why FreeMyTask exists. On Instagram, he channels that same instinct into helping 26,000+ content creators with SEO education, motivation, and hands-on query solving.

Last updated: August 22, 2026
🎁