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.
Related Tools
JSON to XML Converter
Turn JSON data into escaped, indented XML without uploading it.
XML Formatter
Format and indent XML code into a clean, readable structure directly in your browser.
JSON Formatter
Format, validate and beautify JSON for free.
CSV to JSON Converter
Convert CSV files into JSON arrays instantly, right in your browser.
JSON to C# Converter
Generate C# classes from a JSON sample directly in your browser.
JSON to CSV Converter
Convert a JSON array of objects into a CSV file instantly, in your browser.