Something wrong with this tool?
About XML To JSON Converter Online
This tool converts XML into JSON. Element names become keys, text content becomes string values, attributes become specially-prefixed properties, and repeated elements become arrays. The output mirrors the XML structure faithfully.
XML to JSON conversion is common when modernizing systems: consuming SOAP services from a JavaScript codebase, importing legacy XML configurations into a JSON-based pipeline, or building tools that visualize XML data.
Options control attribute handling, namespace handling, and how whitespace between elements is treated. Empty elements can be represented as null, empty string, or empty object.
How to use this tool
How to convert XML to JSON
Paste your XML
Drop an XML document into the "XML" field. The tool uses `fast-xml-parser` with permissive defaults — element text values are trimmed of leading and trailing whitespace.
How attributes are kept
Element attributes ARE preserved with the `@_` prefix. For example `<foo bar="1">x</foo>` becomes `{ foo: { "@_bar": "1", "#text": "x" } }` (the parser uses `attributeNamePrefix: "@_"`).
Press Run
Result is a single `json` field — a JavaScript object reflecting the document tree. The XML prolog and DOCTYPE are dropped; only the element tree survives.
Lossy round-trip
Going XML → JSON → XML through this tool and json-to-xml-converter does NOT round-trip cleanly: attribute prefixes won't match, mixed content (text + child elements) collapses, and ordering of repeated siblings can shift.