100% client-side · nothing leaves your browser

XML to JSON Converter

Convert XML to JSON, or JSON back to XML — attributes, nested elements, and repeated tags are all handled automatically and predictably.

XML input
JSON output

          
Paste XML (or JSON, with the toggle switched) to convert it

How to convert XML to JSON

  1. Paste your XML into the input pane.
  2. Elements become JSON keys, attributes become @attribute keys, and repeated sibling tags become arrays.
  3. The JSON output appears instantly on the right.
  4. Switch the toggle to convert JSON back to XML using the same conventions in reverse.

Why use this converter

Predictable, documented conventions

Attributes always map to @-prefixed keys and repeated tags always become arrays, so the same document converts the same way every time — including back to its original XML shape.

Runs natively in your browser

Uses the browser's built-in XML parser and serializer directly — no server round-trip, no upload.

XML and JSON aren't a perfect match

XML supports concepts JSON doesn't have a native equivalent for — attributes on elements, and "mixed content" where text and child elements interleave. Any XML-to-JSON converter has to make a deliberate choice about how to represent those. This tool's convention: attributes become object keys prefixed with @ (so they never collide with child element names), and any direct text content is stored under a #text key when an element also has attributes or children. Elements that repeat under the same parent — a common XML pattern for lists — automatically become a JSON array rather than overwriting each other.

Converting JSON to XML follows the same rules in reverse, which means a round trip (XML → JSON → XML) preserves the original structure rather than silently losing attributes or collapsing repeated elements.

Frequently asked questions

How are XML attributes represented in the JSON output?

Each XML attribute becomes a JSON key prefixed with @, e.g. <item id="1"> becomes {"@id": "1"}, so attributes and child elements never collide in the output.

What happens to repeated XML tags with the same name?

If an element has multiple children with the same tag name, they're automatically collected into a JSON array under that tag name, rather than overwriting each other.

Is there one single correct way to convert between XML and JSON?

No — XML and JSON have different capabilities (XML has attributes and mixed content; JSON doesn't), so any converter has to make consistent conventions. This tool documents its conventions (the @attribute and #text keys) so the mapping is predictable in both directions.