XML to JSON Converter
Convert XML to JSON with attributes, repeated elements and text handled predictably.
How to use XML to JSON Converter
- Paste XML or open a file.
- Choose whether to keep attributes and whether to convert numbers and booleans.
- Copy or download the JSON.
How it works
Each element becomes a key. Attributes are kept as @name keys, and when an element has attributes or children as well as text, its text is stored under #text. An element with only text becomes a plain string, an empty element becomes null, and child elements that repeat become an array. CDATA is read as text and entities are decoded.
By default every value is a string, because XML itself has no types. Tick Convert numbers and true/false to turn plain numbers and booleans into JSON types; values with leading zeros (007) and numbers longer than 15 digits stay strings so codes and IDs are not altered.
Everything runs in your browser. The text you paste is not uploaded, logged or saved, so configuration files, API responses and customer data stay on your device. The XML must be well-formed; errors are reported with their line and column.
Example
<user id="1"><name>Ada</name><tag>a</tag><tag>b</tag></user> → {"user": {"@id": "1", "name": "Ada", "tag": ["a", "b"]}}.
Frequently asked questions
Why is a single child not an array?
Without a schema there is no way to know that an element may repeat. One occurrence gives a value; two or more give an array. Code that reads the result should accept both.
How are attributes represented?
As keys starting with @, next to child elements. Untick "Keep attributes" to drop them.
Are namespaces handled?
Prefixes are kept as part of the names (soap:Body). Namespace declarations appear as @xmlns attributes.
Is element order preserved?
Within the same name, yes (array order). The relative order of differently named siblings is not something JSON objects are meant to carry.
Limitations
- Mixed content (text interleaved with tags) is flattened: the text pieces are joined under #text.
- Comments and processing instructions are dropped.
- A single occurrence of a repeatable element is not wrapped in an array.
Last reviewed November 9, 2026. How we build and test tools.