XML to JSON
Convert XML to JSON with strict validation and clear line/column error messages.
Runs in your browser — your data never leaves your deviceFree, no sign-up
JSON output
The converted JSON will appear here.
How it works
The input is first validated by a real XML validator — structural problems like mismatched tags are reported with their line and column. The document is then parsed by the fast-xml-parser library: elements become JSON objects, attributes become @-prefixed keys, text content lands under #text, and repeated elements become arrays.
Features
- Input validated first — mismatched tags get line/column errors
- Attribute support (@-prefixed keys) and #text content
- Repeated elements become JSON arrays
- Optional number/boolean conversion
- 100% client-side — nothing leaves your browser
How to use
- Paste XML, or upload a .xml file.
- Choose indentation and whether to convert numbers and booleans.
- Press Convert to JSON, then copy the result or download it as a .json file.
Example
XML:
<deployment>
<name>app</name>
<replicas>4</replicas>
</deployment>
JSON:
{
"deployment": {
"name": "app",
"replicas": 4
}
}Frequently asked questions
- How are XML attributes represented in the JSON?
- Attributes appear under keys prefixed with @, and an element's text content under the key #text. For example, <a id="1">hi</a> becomes {"a": {"@_id": "1", "#text": "hi"}}. This is the standard convention of the underlying fast-xml-parser library, and it keeps attributes and child elements unambiguously separated.
- Does the converter check that my XML is valid?
- Yes. The input is validated before parsing, so mismatched tags, unclosed elements and other structural errors produce a clear message with the line and column where the problem was found. Nothing is converted until the XML passes validation.
- Are numbers and booleans converted automatically?
- By default, yes — <replicas>4</replicas> becomes 4, not "4", and true/false elements become booleans. You can turn this off to keep every value as a string.
- What happens to repeated elements?
- Repeated sibling elements become a JSON array: <ports><port>8080</port><port>8443</port></ports> becomes {"ports": {"port": [8080, 8443]}}. Note the flip side: an element that appears only once becomes a plain value, not a one-element array.
- Are comments, CDATA and processing instructions preserved?
- No. XML comments and processing instructions (including the <?xml?> declaration) are dropped, and CDATA sections are treated as ordinary text content — none of them have a representation in JSON.
- Is my data sent to a server?
- No. Conversion happens entirely in your browser with JavaScript. Nothing you type or paste is transmitted anywhere — you can verify this in your browser's network inspector.