Convert XML to JSON (and vice versa)

Convert an XML document to JSON, or a JSON (in the format produced by this tool) to XML. Attributes become keys prefixed with @, the text becomes a #text key.

Example:

Convert a legacy XML response to JSON

Many legacy APIs (SOAP, industrial data feeds, exports from older systems) still respond in XML, whereas modern JavaScript handles JSON much more naturally. This tool lets you quickly convert an XML response fetched from such an API into usable client-side JSON, or conversely convert it back to XML when a downstream system requires it as input.

How are XML attributes handled when converting to JSON?

Each XML attribute becomes a JSON key prefixed with @ (for example id="1" becomes "@id": "1"), while an element's text content is placed in a #text key. This convention makes it possible to unambiguously distinguish an attribute from text and sub-elements in the resulting JSON structure.

Is the conversion reversible identically?

Converting JSON to XML works well on JSON that follows the @attribute / #text convention produced by this tool, allowing for a consistent round trip. However, arbitrary XML (formatting, comments, whitespace, exact order of elements) isn't guaranteed to be reconstructed byte-for-byte identically after an XML → JSON → XML round trip.

100% local processing: the conversion runs entirely in your browser via WebAssembly, with no data sent to a server.