XML to JSON Converter
Parse XML into structured, indented JSON privately in your browser.
This tool runs entirely in your browser. Your files are never uploaded to a server.
{
"catalog": {
"@lang": "en",
"book": [
{
"@id": "1",
"title": "Example"
},
{
"@id": "2",
"title": "Second"
}
]
}
}What this converter does
Parses one well-formed XML root and produces indented JSON. Element names become keys and XML entities or CDATA content are decoded into strings.
Attributes
Attributes use an @ prefix in JSON. For example, id="7" becomes the key @id, keeping it distinct from a child element named id.
Text content
A text-only element becomes a string. When an element also has attributes or child elements, its non-whitespace text is stored under #text.
Repeated elements
Sibling elements with the same name become an array in encounter order. A name appearing once remains a single value rather than a one-item array.
Validation and safety
Mismatched tags, multiple roots, duplicate attributes and malformed attribute syntax produce an error. DOCTYPE is intentionally rejected to avoid external or custom entity expansion.
Limitations
Mixed-content ordering cannot be represented perfectly by this compact object convention, and namespace prefixes are retained as literal key text rather than resolved.
Privacy
The XML parser and JSON serializer run locally inside the browser. Neither the source document nor its output is uploaded.
Frequently Asked Questions
- How are XML attributes represented in JSON?
- Each attribute becomes a string property prefixed with @, while mixed text uses the reserved #text key.
- What happens to repeated XML elements?
- Repeated sibling elements sharing a name become a JSON array in the same order in which they appeared.
- Does this tool resolve XML DTD entities?
- No. DOCTYPE declarations are rejected deliberately, and the conversion does not make external network requests.