XML to JSON
Processed Client SideConvert XML markup into equivalent, readable JSON — attributes, text nodes, and nesting preserved.
Bookmark this tool now — skip the search next time you need it.
About XML to JSON
This tool runs entirely in your browser. Whatever you paste is processed on your own device and is never uploaded, logged, or sent to any server.
Convert XML markup into equivalent JSON, preserving attributes, text content, and nesting rather than flattening them away. The two formats do not map onto each other perfectly — XML distinguishes between an attribute and a child element, and JSON has no such concept — so the conversion follows the widely used convention of prefixing attribute names with @ and storing element text under a #text key. That keeps the round trip meaningful instead of silently dropping half the document. Type inference is optional, so numeric and boolean strings can become real JSON values or stay as text, depending on what the receiving code expects. Parsing uses the browser XML parser rather than a regular expression, which is why a malformed document is reported as an error instead of converting into something that looks plausible and is wrong.
Key features
- Converts any well-formed XML document into equivalent JSON
- Attributes preserved with an @ prefix, so they stay distinguishable from child elements
- Element text preserved under a #text key when an element has both attributes and content
- Nesting and repeated elements preserved as nested objects and arrays
- Optional type inference, turning numeric and boolean strings into real JSON values
- Parse errors reported when the XML is not well formed, using the browser own XML parser rather than pattern matching
- The root element becomes the single top-level key, so the name of the document survives the conversion
- Syntax-highlighted panes for both the XML input and the JSON output
- Runs entirely in your browser — no upload, no size limit imposed by a server
How to use it
- Paste your XML into the input pane.
- Decide whether you want type inference on or off.
- Click Convert.
- Read the JSON, then copy it.
Tips & common mistakes
- Turn type inference off when the XML holds identifiers, postcodes, or version strings — inference will read 1.10 as the number 1.1 and lose the distinction.
- The @ prefix on attributes and the #text key are conventions, not a standard. If a downstream system expects different markers, rename them after converting.
- XML is stricter than JSON about being well formed: one unclosed tag fails the whole document. The error message names the position, which is usually enough to find it.
- An element that appears once becomes an object and the same element appearing twice becomes an array. Code consuming the result has to handle both, which is the classic XML-to-JSON trap.
- Namespace prefixes are kept as part of the key name, so an element like soap:Body becomes a key containing a colon — quote it when accessing it in JavaScript.
- Comments and processing instructions are not carried across, so keep the original XML if those matter.
- Whitespace between elements is not meaningful in most XML dialects but is preserved inside text content, so an element indented across several lines keeps those newlines in its #text value. Trim it in your own code if it matters.
- SOAP and RSS documents convert well and are the usual reason to reach for this, but both lean heavily on namespaces — check that the prefixed keys survive into whatever consumes the JSON before you rely on it.