Code Beautify / MULTIVERTO

XML to JSON

Map a simple XML document to a JSON object.

Live converterYour input stays in this browser. No text is uploaded for conversion.

The file stays in your browser.
Chain tools

Apply each text tool to the previous result. Text workflows ↗

Only the recipe name and tool order are saved in this browser. Your input and results are never saved.

01 / Example

Example

Your input<person><name>Ada</name><message>Hello</message></person>
Result{ "person": { "name": "Ada", "message": "Hello" } }

02 / Guide

XML to JSON — How it works

What changes in this tool

Map a simple XML document to a JSON object. The XML root becomes the outer JSON property. Attributes appear under @attributes, repeated child names become arrays, and element text becomes a string. Mixed content and advanced XML constructs are outside this explicit mapping, so a round trip may need a schema-aware tool.

Know the format

In the reverse direction, repeated child names become arrays and plain element text becomes a JSON string. Numbers do not retain their numeric type after passing through XML text. Mixed text and children, declarations, comments, CDATA and document types are outside this simple mapping. Use a schema-aware transformer when exact XML semantics matter.

A dependable workflow

Supply a simple well-formed XML document with one root element. The parser groups sibling elements with the same name into arrays and represents attributes and text through reserved JSON fields; a lone child of a name may remain a single value. This shape is a mapping choice, not an intrinsic property of XML. Text-only elements can become JSON strings, while mixed nonblank text with child elements is refused. Entities are decoded under the supported XML rules before producing JSON. Try a source with attributes, repeated children and an empty element to understand how each appears in the result before passing it to another program. In the live example, with line breaks shown as JSON escapes, input "<person><name>Ada</name><message>Hello</message></person>" produces output "{\n \"person\": {\n \"name\": \"Ada\",\n \"message\": \"Hello\"\n }\n}". For an XML record with one address and another with two addresses, compare the resulting JSON property shapes. The second can become an array while the first remains a single value. A client that expects a stable array needs a normalization step after conversion, with its schema applied explicitly.

Check the result

Turn a simple XML response into JSON when a consumer expects an object. Inspect how repeated sibling elements become arrays and how attributes move into @attributes; a single child and repeated children can therefore have different JSON shapes. Test text and entities separately. Mixed text around child elements is rejected to prevent silent loss of ordering. Compare the JSON tree to the XML hierarchy rather than comparing line counts. Check whether a receiver expects an array for a child name even when the sample has only one occurrence. Attribute values and element text arrive as strings; an application schema must interpret dates or numbers. If the XML relies on mixed content, comments, declarations or other unsupported constructs, investigate those requirements with a full XML parser. Keep the original XML when editing the JSON because rebuilding the document may not preserve every representational detail of the source.

How this conversion transforms the input
XML — Input
Read and transform structure
JSON — Result

Explore guides

Conversion guides

Explore guides