←
Data

XML to JSON

Loading the tool…

Ready when you are.Runs in this browser · nothing is uploaded

Convert XML ⇄ JSON

  • Free
  • No sign-up
  • No upload
  • Works offline

Tool facts

Opens
XMLJSONSVGRSSATOMKMLGPX
Saves as
JSONXML
Price
Free, no sign-up, no watermark
Are files uploaded?
No. Everything is processed in this browser, on your device.
Batch processing
One file at a time
Offline use
Works without a connection once this page has loaded
Browser
A recent Chrome, Edge, Firefox or Safari, on computer or phone.

Check it yourself: press F12, open the Network tab, then use the tool. No request carries your data.

About XML to JSON

XML to JSON converts an XML document into JSON and JSON back into XML. Each element becomes a property named after its tag, attributes become properties prefixed with @ (for example @id), and text that sits next to attributes or child elements is stored under #text. Elements that repeat, such as several <author> tags, become a JSON array, while single elements stay plain values.

The XML is read with the browser's built-in XML parser, so malformed documents are reported instead of being converted half-way. CDATA sections are kept as text, comments are ignored and namespace prefixes stay part of the names. In the other direction the same conventions are applied: @ keys become attributes, arrays become repeated elements and invalid characters in names are replaced. Options detect numbers and booleans, or force every element into an array for a predictable structure.

XML to JSON runs entirely in your browser. Your data is processed on your device and is never uploaded to Qiyi or anyone else.

How to use XML to JSON

  1. Paste XML or JSON into the input box, or drop an .xml or .json file; the direction is chosen from the file type.
  2. Check that Direction shows XML → JSON or JSON → XML.
  3. Set options such as Detect numbers and booleans, Always use arrays, Root element name and Indentation.
  4. Click Copy or Download, or Swap to convert the result back.

Frequently asked questions

How are XML attributes represented in JSON?

Each attribute becomes a property whose name starts with @, so <book id="b1"> becomes {"book": {"@id": "b1"}}. When an element has attributes and text, the text is stored under #text, for example <price currency="EUR">39.90</price> becomes {"@currency": "EUR", "#text": 39.9}.

Why is an element sometimes an array and sometimes an object?

XML does not say whether an element can repeat, so the converter makes an array only when the same tag appears more than once inside the same parent. If your code always expects arrays, turn on Always use arrays and every child element is wrapped in an array, even when it appears once.

Is the conversion lossless?

For data-style XML, converting to JSON and back produces equivalent XML. Comments, processing instructions, the order of mixed text and elements and the exact formatting are not kept, because JSON has no place for them. Number detection can also drop trailing zeros, so turn it off to keep values exactly as written.

What does the converter do with JSON that has several top-level keys?

XML needs exactly one root element. If the JSON object has a single key, that key becomes the root. Otherwise everything is wrapped in the root element named in the Root element name box, and a top-level array becomes a series of <item> elements.

Can it convert RSS feeds, SVG or SOAP messages?

Yes. Any well-formed XML works, including RSS and Atom feeds, SVG images, KML and GPX files and SOAP envelopes. Namespace prefixes such as soap:Envelope are kept in the property names.

· Free · Runs in this browser · nothing is uploaded

Drop any file here
Drop it to see which tools can open it