XML to JSON Converter

Paste XML, get JSON as you type

Input XML

Output JSON

Paste your XML on the left and the JSON shows up here.

Or drop a file on this box, , or .

What is XML to JSON Converter?

Need to convert your XML to JSON? This tool does that. 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. To check the result by eye, paste it into the JSON parser on our home page: repeated elements turn into table rows and @attributes shows up as a small table inside its cell.

How to Use XML to JSON

Paste, read, save. The JSON is rebuilt each time the input changes, which is why the page has no Convert button.

1

Paste, Upload, or Load Sample

Paste XML into the left Input XML panel or use Upload for a .xml file; a byte-order mark at the start is ignored. Sample loads two subscriber elements, each with an id attribute, one carrying an escaped AT&amp;T. Example:

<subscribers><subscriber><subscriberId>SUB-1001</subscriberId><plan>Unlimited 5G</plan><dataUsage>45.2</dataUsage></subscriber></subscribers>

Clear empties both panels. The gear icon opens a Compact output checkbox for single-line JSON. Malformed XML puts a red message above the output, usually with the line and column the browser stopped at, such as "Invalid XML: error on line 3 at column 12: ...".

2

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.

3

Download or Copy

Download writes the result to converted.json; Copy puts it on the clipboard for a test fixture or a request body.

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

A vendor sends an RSS feed or a SOAP response, and your dashboard or Node script wants JSON. Convert one real response here to see the exact shape you will be indexing into before you write the mapping code.

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. The browser's own DOMParser reads the XML inside this tab and no request is made with it. To keep the page responsive, anything over 5 MB is turned away with a message asking you to split the file.

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 sections are read as ordinary text. Mixed content loses its ordering: in <note>Call <b>Ingrid</b> before noon</note> the b child becomes a key and the loose text is trimmed and joined into "#text": "Call before noon", so the JSON no longer shows that the name sat between the two pieces.

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

If the XML needs checking first, or you want CSV or YAML instead of JSON, these are the neighbours: