XML to JSON Converter
Paste XML, get JSON as you type
Input XML
Output JSON
What is XML to JSON Converter?
Need to convert your XML to JSON? This tool does that instantly. JSON is the standard for modern APIs (see the JSON RFC 8259 specification), while XML is common in legacy systems. Convert between them whenever you need.
The mapping is predictable, so you can write code against it. The root element becomes the top-level key, child elements become nested keys, and an element that appears more than once becomes an array. Attributes sit under @attributes, and text that sits next to attributes or child elements goes under #text. CDATA is treated as ordinary text, and empty elements become null.
XML has no data types, so every value comes out as a JSON string: <monthlyGb>38.6</monthlyGb> becomes "38.6", not 38.6. That keeps zip codes and long IDs intact; convert the fields you need to numbers in your own code. Everything happens in your browser and nothing is uploaded. The output is plain JSON that JSON.parse reads directly.
How to Use XML to JSON
Follow these steps to convert XML to JSON. Each step uses the actual buttons and panels on this page.
Paste, Upload, or Load Sample
Paste XML into the left Input XML panel, or click Upload to load a .xml file. Click Sample to load example telecomm XML. Example:
<subscribers><subscriber><subscriberId>SUB-1001</subscriberId><plan>Unlimited 5G</plan><dataUsage>45.2</dataUsage></subscriber></subscribers>Use Clear to start fresh. Tick Compact output in the settings panel (gear icon) for single-line JSON. If the XML is not well-formed, the parser's error appears above the output.
View JSON Output
The right Output JSON panel updates as you type. For the sample you get {"subscribers": {"subscriber": [ ... ]}}, with each subscriber's id attribute under @attributes.
Download or Copy
Click Download to save converted.json, or Copy to copy it to your clipboard.
When You'd Actually Use This
API Migration
Migrate from SOAP APIs (XML) to REST APIs (JSON). Convert XML responses to JSON format when modernizing your API integrations.
Legacy System Integration
Convert XML data from legacy systems to JSON for use in modern applications. Great for bridging old and new systems.
Format Compatibility
Some modern tools require JSON format. Convert your XML data to JSON when working with tools or systems that only accept JSON.
Data Transformation
Transform XML data to JSON for easier processing in JavaScript applications. JSON is native to JavaScript, making it easier to work with.
Common Questions
Is my XML uploaded?
No. Conversion happens in your browser; your XML never leaves your computer. Inputs over 5 MB are refused.
Are numbers and booleans converted?
No, every value is a string. XML text carries no type, and guessing would break values like 02134 or an 18-digit ID. Parse the fields you need after converting.
Where do XML attributes end up in the JSON?
They go under an @attributes object on their element: <price currency="USD">9.99</price> becomes {"@attributes": {"currency": "USD"}, "#text": "9.99"}.
What about mixed content and CDATA?
CDATA content is read as plain text. In mixed content like <p>Hi <b>Ava</b> there</p>, the child elements become keys and the text pieces are trimmed and joined into #text ("Hi there"); where the text sat relative to the children is lost.
Can I convert JSON back to XML?
Yes. The JSON to XML converter understands the same @attributes and #text keys, so a round trip keeps attributes. Comments and processing instructions are not carried over in either direction.
Why is an element sometimes an array and sometimes not?
An element becomes an array only where it repeats. If an order has one <item> in one document and three in another, you get an object in the first and an array in the second, so normalise that in your code if it matters.
Other XML Tools You Might Need
Conversion is just one XML task. Here are other tools that work well together: