Runs 100% in your browser — nothing is uploaded
JSON & Data Formats

XML → JSON Converter

Convert XML documents to structured JSON with configurable number/boolean parsing.

XML → JSON Converter
Client-side

About this tool

The XML to JSON Converter parses any XML document and outputs an equivalent JSON representation, using fast-xml-parser's battle-tested parsing engine. This is a common integration task: many legacy APIs, SOAP services, and enterprise systems still speak XML, while modern frontends and JSON-based tooling expect JSON.

Element text content becomes JSON values, nested elements become nested objects, and repeated sibling elements automatically become JSON arrays. Attributes are preserved using the conventional @_ prefix (e.g. an id="42" attribute on a <user> element becomes "@_id": 42 inside the user object) — the same convention used by fast-xml-parser and many other XML-to-JSON libraries, so output is compatible with tools expecting this format.

A "parse numbers/booleans" toggle controls whether numeric-looking text (like <price>29.99</price>) and boolean-looking text (true/false) are converted to native JSON number and boolean types, or kept as strings. Turn it off when you need to preserve exact string formatting, such as leading zeros in IDs.

Parsing runs entirely in your browser. Malformed XML is caught and reported with a clear error message rather than silently producing partial or incorrect output.

FAQ

What does the @_ prefix mean in the output?
XML attributes have no direct JSON equivalent, so they are represented as object keys prefixed with @_ (e.g. @_id) to distinguish them from child elements and text content. This is the standard convention used by fast-xml-parser.
What happens to repeated sibling elements?
When an element appears multiple times as a sibling (e.g. multiple <role> tags inside <roles>), they are automatically collected into a JSON array. A single occurrence remains a plain object or value.
Should I turn parse numbers/booleans on or off?
Turn it on for typical data conversion where <count>5</count> should become the number 5. Turn it off if your XML contains numeric-looking strings that must stay strings, like zip codes or IDs with leading zeros.
What happens with invalid XML?
The converter validates the document first and shows a specific parser error (with line/column when available) instead of attempting to guess at a partial conversion.
Are XML comments and processing instructions included?
Comments are stripped during conversion since JSON has no comment syntax. The XML declaration and other processing instructions are not included in the JSON output — only element structure, attributes, and text content are converted.