#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
⚡ FREE · INSTANT

XML to JSON Converter: Turn XML into Clean, Usable JSON

Paste XML and get JSON with attributes, arrays and types handled sensibly.

  • 🏷️ Attributes as @keys
  • 📚 Repeats become arrays
  • 🔢 Numbers kept as numbers

How to use the XML to JSON Converter

  1. 1. Paste XMLA feed, API response or config file.
  2. 2. Pick optionsThe attribute prefix, and whether to turn numbers and booleans into JSON types.
  3. 3. Copy the JSONConvert and copy or download the result.

How the XML is mapped

XML and JSON don't line up exactly, so a converter has to choose rules. This one uses the most common conventions:

  • Each element becomes a key with its name.
  • Attributes become keys with a prefix, @ by default, so id="1" becomes "@id": 1.
  • Elements repeated under the same parent become an array.
  • An element with only text becomes that value; text next to child elements goes into #text.
  • Empty elements become null.
  • With type conversion on, 88 becomes a number and true becomes a boolean. Values with leading zeros, like 007 or a PIN code, stay as text.

Worked example

The sample has a students root with a batch attribute, two student elements and a mentor. 8 XML elements are converted, and the result is:

{
  "students": {
    "@batch": 2026,
    "student": [
      { "@id": 1, "name": "Asha", "marks": 88 },
      { "@id": 2, "name": "Rahul", "marks": 74 }
    ],
    "mentor": "Meera"
  }
}

Because there are two student elements, they become an array. A catch to watch for: if the XML had only one student, it would be a single object, not an array of one. Code that reads converted XML should handle both cases, or always wrap the value in an array.

Frequently asked questions

Can it convert JSON back to XML?

Not in this tool. JSON to XML needs extra choices, like which keys become attributes.

Are namespaces kept?

Element names keep their prefixes, such as soap:Body. Namespace declarations show up as @xmlns attributes.

Why is my PIN code a string?

Values starting with 0 are kept as text so leading zeros are not lost.

Is the xml to json converter free?

Yes, it is free. Your first conversion asks for your name and WhatsApp number once, and after that the xml to json converter and every other Uncodemy tool open without the form.

More free tools

See all free tools