XML to JSON Converter

Paste XML and click Convert to JSON. You get formatted JSON you can use in JavaScript, APIs or tests, with the XML checked for errors first.

Editor (Formatted View)
1
Ready — paste or type XML here
Viewer
Tree view will appear here after formatting
Ready

How to convert XML to JSON

  1. Paste XML into the editor, or load a file.
  2. Click Convert to JSON. If the XML isn't well-formed, click Format to see exactly where, and Repair to close unclosed tags and fix common mistakes.
  3. Copy or download the JSON from the result panel.

How XML maps to JSON

XMLJSON
The root elementIts contents become the top-level object
<name>Ada</name>"name": "Ada"
Attributes <user id="7">Keys next to the child elements: "id": "7"
Repeated elements with the same nameAn array
Nested elementsNested objects
Text next to attributes <price currency="EUR">9.5</price>{"currency": "EUR", "": "9.5"}

For example:

<order id="17">
  <item>Pen</item>
  <item>Book</item>
</order>

becomes {"id": "17", "item": ["Pen", "Book"]}.

Things to know

Conversion runs on our server in memory; the data isn't stored.

Frequently asked questions

How are XML attributes converted?

Attributes become ordinary keys in the JSON object, next to the child elements, without a prefix. For <user id="7"><name>Ada</name></user> you get {"id": "7", "name": "Ada"}.

Why are my numbers strings in the JSON?

XML stores everything as text and doesn't say whether 42 is a number or a string, so the converter keeps values as strings. Convert them where you use the data.

How are repeated elements handled?

Elements with the same name under the same parent become a JSON array. An element that appears only once becomes a single value.

What happens to the root element?

Its name is dropped and its attributes and children become the top-level JSON object.

Is my XML stored?

No. It's converted on our server in memory and sent straight back.

Other tools

Share Content

Choose what to share and generate an instant link

🔥 One-time link Content deleted from server after first view
✉️
Uploading to server…