XML to JSON — Guide

Convert XML data to JSON format.

What it is and when to use it

JSON is the lingua franca of modern APIs, but plenty of systems still emit XML. This tool parses an XML document and projects it into JSON: elements become objects, repeated elements become arrays, and attributes and text are given distinct keys so neither is lost. The mapping is not unique — XML carries more structure than JSON in places (attributes, mixed content) — so the output uses a consistent convention (commonly attributes under an "@" key and text under "#text") that you can rely on when parsing it downstream.

Converts XML into JSON for integrating with modern APIs.

How to use it

  1. Paste the XML
  2. Get the JSON result
  3. Copy and use it

A worked example

Fill in sample XML

<user id="1"><name>Alice</name></user>

Copy this into the tool, or open XML to JSON

Things that trip people up

  • XML attributes and text nodes are represented by different fields in JSON — check the output after converting

Questions people ask

Where do XML attributes go in the JSON?
This tool puts attributes under a dedicated key (typically @) and element text under another (typically #text), so <user id="1">Alice</user> becomes { "user": { "@id": "1", "#text": "Alice" } }. The exact key names follow the converter's convention — read one sample before trusting the shape in code.
Why did my repeated tags become an array?
JSON has real arrays; XML does not. When the same child element appears more than once, the converter groups them into an array so order and multiplicity are preserved. A single occurrence stays a single object unless the schema marks it as a list.
How do I convert back to XML?
Use the JSON-to-XML tool. Keep in mind the round trip is not perfectly symmetric: attributes that became @ keys must be re-special-cased, and any typing XML lost (everything is text) will not magically return.

Next steps

Open the XML to JSON tool

Spotted something wrong on this page? Tell us via Contact Us