Guides Knowledge Base

XML to JSON Converter

Convert XML to JSON online. Paste a SOAP response, RSS feed or legacy config and get JSON back with elements as keys. Free, runs entirely in your browser.

Switch the direction selector to XML → JSON, paste your XML, and each element becomes an object key, text content becomes the value, and repeated sibling elements collapse into a JSON array.

XML Has Concepts JSON Does Not

The two models do not line up one-to-one, so any conversion has to make choices. Three differences matter in practice:

  • Attributes vs child elements. XML distinguishes <user id="1"/> from <user><id>1</id></user>; JSON has only keys, so attributes are folded in alongside child elements.
  • Repetition is implicit. One <item> looks like a single value, two look like an array. A document with exactly one item therefore produces an object where your code may expect a one-element array — normalise on the consuming side.
  • Mixed content. Text interleaved with child elements, as in <p>see <b>this</b> now</p>, has no natural JSON shape and does not survive cleanly.

Namespaces

Prefixes such as soap:Envelope are kept as part of the key name, since JSON has no namespace mechanism to move them into. Expect keys containing a colon, and quote them when you reference them in code.

On the Command Line

# Python, using xmltodict
python3 -c "import sys,xmltodict,json; json.dump(xmltodict.parse(sys.stdin.read()), sys.stdout, indent=2)" < in.xml

# Node.js, using fast-xml-parser
node -e "const{XMLParser}=require('fast-xml-parser');console.log(JSON.stringify(new XMLParser().parse(require('fs').readFileSync(0,'utf8')),null,2))" < in.xml

Who this guide is for

  • Turn a SOAP response into JSON your frontend can consume
  • Convert an RSS or Atom feed into JSON for a reader UI
  • Migrate a legacy XML config file to JSON
  • Inspect a verbose XML payload in a more compact shape

Try the free JSON to XML

Runs entirely in your browser — no upload, no signup, and your data never leaves your device.

Open JSON to XML

Frequently Asked Questions

Is XML to JSON lossless?

No, and it cannot be. Attributes, namespaces, comments, processing instructions, and mixed content have no exact JSON equivalent. Keep the XML if you need a faithful original.

Why is a single element an object instead of an array?

Repetition in XML is implicit, so one <item> is indistinguishable from a scalar field. Coerce the value to an array in your consuming code when a list is expected.

Can it convert a whole SOAP envelope?

Yes. The envelope, header, and body all convert, with namespace prefixes retained in the key names — usually you then read the one body element you care about.

Tools mentioned in this guide

Related JSON Topics & Reference Articles