How to Convert XML to JSON
Paste Your XML
Paste a complete XML document into the input field, including its single root element. The converter parses the markup with your browser's built-in DOMParser, so nothing leaves your device. Well-formed XML with one top-level element gives the cleanest result.
Click Convert to JSON
The tool walks the parsed tree and builds a matching JSON object. Element attributes are grouped under an "@attributes" key, plain text content becomes a string, and elements that share the same tag name are collected into an array so nothing is lost.
Copy the Output
The JSON appears pretty-printed with two-space indentation in the output panel. Use the Copy button to send it to your clipboard, then paste it straight into your code, config file, or API request. Clear resets both panels when you are ready for the next document.
How XML Structures Map to JSON
This converter follows a consistent set of rules when it turns XML nodes into JSON. Knowing how each structure is represented helps you predict the output and write code that reads it correctly.
| XML Structure | JSON Result |
|---|---|
| Root element | Kept as the single top-level key wrapping the whole object |
| Attributes (id="1") | Grouped together under an "@attributes" object on that element |
| Text inside an element | A plain string value, or a "#text" key when the element also has attributes |
| Nested child elements | Nested objects keyed by their tag name |
| Repeated sibling tags | Collected into a JSON array under the shared tag name |
| Empty element | An empty string or empty object, depending on its attributes |
When This Converter Fits
Reading API Feeds
Turn legacy XML responses and data feeds into JSON so modern JavaScript, fetch calls, and front-end frameworks can consume them without an extra parsing layer.
Inspecting Config Files
Convert dense XML config or manifest files into indented JSON to read the structure at a glance, then copy the parts you actually need.
Sensitive Data
Because parsing runs entirely in your browser and nothing is uploaded, you can convert internal or confidential XML without sending it to any server.
Quick One-Off Jobs
For a single document you need converted right now, paste, click, and copy. No install, no account, and no command-line tooling to set up.
Common Problems and Fixes
Invalid XML error appears
The browser parser rejected your input. Check for an unclosed tag, a missing root element, or a stray ampersand or angle bracket that is not escaped as & or <. The status line shows the first parse error to point you at the spot.
Attributes look unexpected
Attributes are not inlined next to text; they are placed in an "@attributes" object on the same element. Read values from element["@attributes"].name in your code rather than expecting a flat property.
One item became an object, not an array
A tag is only turned into an array when it appears more than once under the same parent. A single occurrence stays an object, so guard for both shapes when iterating over the output.
Large file feels slow
Everything runs on your device, so very large documents are bound by your browser's memory. If the page stalls, split the XML into smaller chunks or keep inputs to a few megabytes for the smoothest results.