XML to JSON

Convert XML to JSON online. Handles attributes (@attributes), text nodes (#text), repeated elements as arrays, and type coercion. 100% client-side.

100% private · runs locally

Convert XML documents to JSON objects in-browser. Attributes are mapped to @attributes, text content to #text, and repeated sibling elements automatically become arrays. Numeric and boolean strings are coerced to their native types.

XML input
JSON output JSON

Related tools

Frequently asked questions

How are XML attributes handled?

When "Include @attributes" is enabled, each element's attributes are grouped under an @attributes key. For example, <book category="fiction"> becomes {"{ '@attributes': { 'category': 'fiction' } }"}. Disable the option to drop all attributes from the output.

How are repeated XML elements handled?

When multiple sibling elements share the same tag name, they are automatically converted to a JSON array. For example, three <book> siblings become {'{ "book": [...] }'}. Enable "Always use arrays" to force single elements into arrays too — useful for consistent API response handling.

What is #text?

When an XML element has both child elements and text content (mixed content), the text is stored under a #text key. For leaf elements (no child elements), the value is returned directly as a string, number, or boolean — no wrapper key needed.

Are numeric strings coerced to numbers?

Yes, for leaf text nodes. If a text value is a valid number (e.g. 30.00), it becomes a JSON number. true and false become JSON booleans. This behavior is standard across most XML-to-JSON conversion libraries.

Is there a standard for XML-to-JSON conversion?

No universal standard exists. Different tools use different conventions for attributes, text content, and arrays. This tool follows the BadgerFish-adjacent convention (@attributes, #text), which is popular in JavaScript libraries. If you need a specific convention, the output may need post-processing.