XML ↔ JSON Converter

Convert XML documents to JSON and JSON back to XML.

Indent:
XML INPUT
JSON OUTPUT

What Is XML to JSON Conversion?

XML and JSON are two of the most common data interchange formats. This XML to JSON converter transforms XML documents into JSON objects and converts JSON back to XML — all in your browser. It handles XML attributes (mapped to @_-prefixed keys), nested elements, and repeated elements as arrays. The tool is useful for working with legacy XML APIs, migrating data formats, or debugging XML payloads.

How to Use XML ↔ JSON Converter

  1. Select the conversion direction: XML → JSON or JSON → XML.
  2. Paste your input into the left panel, or click Load Sample.
  3. Click Convert to run the conversion.
  4. The result appears in the right panel. Click Copy to copy it.
  5. Use the ⇄ Swap button to flip the direction and use the output as new input.

Features

  • Bidirectional — convert XML to JSON and JSON to XML
  • Attribute support — XML attributes mapped to @_-prefixed JSON keys
  • Configurable JSON indent — 2 or 4 spaces
  • Swap button — flip direction and reuse output as input
  • Privacy-first — all processing is local, nothing is uploaded

FAQ

How are XML attributes handled in JSON?

XML attributes are converted to JSON keys prefixed with @_. For example, <book category="fiction"> becomes { "@_category": "fiction" } in JSON. This prefix is also used when converting JSON back to XML.

Are XML namespaces supported?

Basic XML namespaces are preserved in the output. Complex namespace handling may require manual adjustment after conversion.

What happens to XML comments during conversion?

XML comments are not preserved when converting to JSON, since JSON has no comment syntax. When converting JSON back to XML, no comments are added.

Is my data sent to a server?

No. All conversion runs entirely in your browser using the fast-xml-parser library. No data is sent to any server.