What is XML to JSON Converter?

XML to JSON Converter turns XML documents into structured JSON instantly. Handles attributes, nested elements, text nodes, CDATA sections, and namespaces. Useful when migrating XML APIs to JSON-based systems or working with XML data in JavaScript.

The converter uses fast-xml-parser under the hood, so it handles real-world XML including namespaces, CDATA blocks, mixed content, and arbitrarily deep nesting. Attributes get prefixed with @_ in the output, repeated elements collapse into arrays automatically, and you can toggle compact mode for one-line output or pretty-printed indentation of 2 or 4 spaces.

How to use

  1. Step 1 — Paste your XML content or upload an XML file. The converter validates the structure and shows any parsing errors immediately.
  2. Step 2 — Configure conversion options: whether to keep attributes (as @attr), collapse text-only elements, or preserve arrays for repeated elements.
  3. Step 3 — Copy the formatted JSON output or download it as a .json file.

When to use

  • Modernising a legacy SOAP or RSS feed for a JavaScript frontend that expects JSON.
  • Loading XML survey or test result data into a NoSQL database that stores documents as JSON.
  • Pulling configuration from a vendor's XML export and rewriting it for a YAML or JSON pipeline.

Result

You receive a SOAP API response in XML with nested product elements and attributes. Paste it in to get clean JSON where <product id="123"><name>Widget</name></product> becomes {"product":{"@id":"123","name":"Widget"}} — ready for your frontend code.

FAQ

How are XML attributes represented in the JSON output?
Attributes get the @_ prefix to distinguish them from child elements. So <book id="42"><title>Hi</title></book> becomes {"book":{"@_id":"42","title":"Hi"}}. Toggle Keep Attributes off to drop them entirely if your downstream code only needs element content.
What happens when an XML element repeats, like multiple <item> tags?
Repeated elements collapse into a JSON array automatically. The first occurrence creates the array, subsequent siblings append to it, and singletons stay as plain objects. This matches the convention most JSON consumers expect from converted feeds.
Does it handle CDATA sections, namespaces, and comments?
CDATA content is preserved verbatim under a #cdata key. Namespaces are kept as part of the element name (xmlns:prefix stays attached). XML comments are dropped, since JSON has no comment syntax to map them to.
Why are my numbers coming out as strings instead of numbers?
By default the converter coerces numeric text to numbers and true/false text to booleans, so 42 becomes 42 not "42". Turn off Parse numbers and booleans in Settings when your API consumer expects every value as a string, or when leading zeros and ID-like fields must stay intact.
What size XML can the converter handle?
It runs entirely on your device, so the practical ceiling is your RAM, typically tens of megabytes for a single document. Very large feeds (gigabytes) need a streaming parser instead, but for normal API payloads, exports, and configs you'll never hit a limit.

Related Tools