XML and JSON describe trees differently. XML has attributes, namespaces and mixed text, while JSON has objects, arrays and scalar values. This converter uses a documented mapping so the result is predictable. It rejects DOCTYPE declarations instead of expanding custom entities, and it never sends your source document to a server.
XML to JSON Converter
Runs entirely in your browser - no upload, no sign-up.
How do you convert XML to JSON?
Paste well-formed XML and this XML to JSON converter maps elements to object keys, repeated sibling tags to arrays, attributes to @-prefixed properties, and mixed text to #text. It keeps scalar text as strings, formats the result for reading or code, and runs entirely in your browser.
How to use
- 01Paste XML
Enter one well-formed XML document or load the example to see the mapping.
- 02Choose the JSON format
Select indentation and decide whether @-prefixed attribute properties should be included.
- 03Review the conversion
Check the root object, arrays made from repeated tags, and any #text properties.
- 04Copy or download JSON
Copy the result to your clipboard or save it as a .json file.
Who it's for
- API developers can turn SOAP or legacy service responses into JSON fixtures for tests and debugging.
- Data teams can inspect product feeds, RSS documents and configuration exports with familiar JSON tooling.
- Frontend developers can convert small XML samples before adapting them to application models.
- Technical writers can make nested XML examples easier to scan and explain.
FAQ
Is my XML uploaded?
No. Parsing and conversion happen locally in your browser, and the document is not sent to a conversion service. The converter uses a pure JavaScript parser in the page, which also means it can work after the page has loaded even if your connection drops.
Is this XML to JSON converter free?
Yes. You can convert XML, change the output formatting, copy the JSON and download a .json file without paying or creating an account. There is no usage counter. Practical limits depend on the memory and processing power available to your browser.
How are XML attributes represented in JSON?
Each XML attribute becomes a property prefixed with @ on its element. For example, <book id="42"> becomes an object with an @id property. Turn off Keep attributes when you only need the element hierarchy and text values.
How are repeated XML elements converted?
Sibling elements with the same name become a JSON array, while a single element becomes one property value. This common compact mapping is data-dependent, so code consuming variable feeds should allow for either one value or an array unless the source schema guarantees repetition.
Does the converter support namespaces and CDATA?
Yes. Namespace prefixes remain in element and attribute names, and CDATA content is treated as text. Namespace declarations are attributes when attribute preservation is on. Comments and processing instructions are ignored because standard JSON has no direct equivalent for them.
Why are XML numbers and booleans JSON strings?
XML text has no built-in JSON-style number or boolean type without a schema. Keeping text as strings preserves exact source values, including leading zeros and large identifiers. Convert fields to application-specific types later when you know the schema and intended meaning.
What XML cannot be converted?
The input must contain one well-formed root element with matching tags and quoted attributes. DOCTYPE and custom entity declarations are rejected for predictable local parsing. Mixed text is collected under #text, so its exact order around child elements cannot be represented by this compact object mapping.