XML to JSON
Convert XML to JSON without uploading it. Keep attributes and repeated elements in a clear JSON structure. Check the result, then copy or download it.
Pasted text or .xml and .txt files, up to 10 MB
Paste XML, drop a file here, or choose a .xml or .txt file. Files stay in your browser.
Your JSON will appear here after conversion.
How XML becomes JSON
Paste XML or choose a local file, then convert it into valid JSON. The document root remains the top-level key. Conversion runs in a Web Worker in your browser; the XML is not uploaded.
Mapping rules
| XML input | JSON output |
|---|---|
<name>Maya</name> | "name": "Maya". Text values stay strings, including numbers such as 001. |
<order id="A-104"> | The attribute becomes "@_id": "A-104". Choose @id if your importer uses that convention. |
Two or more sibling <tag> elements | They become a "tag" array, in source order. Turn on “Always use arrays” for consistent arrays even when one element appears. |
| Text and child elements together | #text holds the combined text; #content keeps text and child elements in source order. |
| An empty element or CDATA | <empty/> becomes an empty string. CDATA becomes ordinary text. XML entities are decoded. |
Example
<person id="7"><name>Maya</name><name>Luis</name></person> becomes {"person":{"@_id":"7","name":["Maya","Luis"]}}. Use Pretty print to make the output easier to read, or turn it off for compact JSON.
XML has attributes, namespaces, comments and mixed content; JSON has no single standard way to represent them. This converter keeps namespace prefixes in names and omits comments and processing instructions. Simple text and #text are trimmed; #content retains the spaces around inline elements. It rejects DOCTYPE declarations and malformed XML, with a line and column for syntax errors.
Choose a .xml or .txt file up to 10 MB. Copy the complete JSON or download a .json file. Large inputs can take longer on a phone. Need spreadsheet rows instead? Try XML to CSV.