JSON & DATA · CONVERTER

XML to JSON Converter

Convert an XML document into readable JSON. The root name is retained, attributes are grouped, repeated sibling tags become arrays, and text stays a string unless you turn on simple type inference.

Native XML parser · Repeated-tag arrays · DOCTYPE blocked · Local processing
Going the other way? JSON to XML →Input limit: 1 MiB · Output limit: 5 MiB · Custom DTD entities are blocked.
Paste XML or open an .xml file. Select Convert for larger documents.
XML input
By default, XML text stays a string.
JSON output
Root: —Elements: 0Attributes: 0Arrays: 0JSON: 0 B
Runs locally · No DTD expansion

XML-to-JSON mapping

  • The root element name is preserved as the top-level JSON key.
  • Attributes are grouped in an @attributes object. Direct text is a string; a text-only element becomes a string value.
  • Repeated child elements with the same qualified tag name become an array. A single child stays a single value.
  • Empty tags become empty strings. Comments and processing instructions are ignored. For mixed content, direct text is collected under #text; the original interleaving of text and child markup is not represented.

Types, safety and privacy

Text stays a string by default, which avoids guessing whether values such as dates, leading-zero codes or identifiers are numbers. Optional inference converts exact true, false and null, plus safe numeric forms; large integers and text with surrounding whitespace stay strings.

The tool uses the browser's native XML parser and does not fetch external resources. DOCTYPE declarations are rejected. Input is limited to 1 MiB, nesting to 256 levels, elements to 100,000, and formatted JSON to 5 MiB.

XML to JSON FAQs

Attributes are collected under @attributes so they do not collide with child element names. Each attribute value remains a string.

No. A child tag becomes an array only when its parent has two or more children with that same qualified name.

Custom DTD entity declarations can make conversion ambiguous and can cause unexpectedly large expansion. The converter rejects DOCTYPE and relies on the browser parser for built-in XML entities.

No. Type inference is off by default. Even when enabled, leading-zero numeric strings and unsafe large integers stay strings.

No. Parsing and conversion happen locally in your browser; the page does not upload or save the XML.