XML to JSON Converter

Instantly turn your XML tags into easy-to-use JSON objects. Secure, browser-based conversion for developers.

XML Input
JSON Output

Turn XML into Easy-to-Use JSON

If you build web or mobile apps, JSON is probably your default data format — JavaScript reads it natively and every modern framework supports it. But data often arrives as XML: RSS feeds, sitemaps, SOAP API responses, exports from older software or government data files. This converter reads XML and produces clean, formatted JSON you can drop straight into your code.

How to Use the XML to JSON Converter

  1. Paste your XML into the input panel, or click Load Sample.
  2. Click Convert to JSON.
  3. Copy the JSON from the output panel.

If the XML is not well-formed — for example a missing closing tag or an unescaped & — you’ll get an error. Our XML Formatter can help locate the problem.

Example

XML input:

<library>
  <book id="1">
    <title>Godaan</title>
    <author>Premchand</author>
  </book>
  <book id="2">
    <title>Gitanjali</title>
    <author>Rabindranath Tagore</author>
  </book>
</library>

JSON output:

{
  "library": {
    "book": [
      { "@id": "1", "title": "Godaan", "author": "Premchand" },
      { "@id": "2", "title": "Gitanjali", "author": "Rabindranath Tagore" }
    ]
  }
}

Because <book> appears twice, the converter groups both into an array, and each id attribute becomes an @id key.

How XML Maps to JSON

XMLJSON
Root elementTop-level key
Child elementNested key
Element textString value
Repeated elementsArray
Attribute id="7"Key "@id": "7"
Text alongside attributesKey "#text"

Tips for Working with Converted Data

  • Convert types: values like "10" and "true" are strings. Use Number() or a comparison in your code.
  • Normalise arrays: if an element might appear once or many times, wrap single values in an array so your loops always work: [].concat(data.library.book).
  • Watch namespaces: prefixed tags such as <media:content> in feeds keep their prefix in the key name.
  • Large files: for very large XML files or automated pipelines, use a library in your backend (for example simplexml_load_string in PHP or xmltodict in Python).

Common Use Cases

  • Showing blog or news RSS items in a React or Vue app.
  • Reading SOAP API responses in a JavaScript front end.
  • Migrating data from legacy systems to a modern database.
  • Inspecting a sitemap’s URLs as a list.

Related Tools

Frequently Asked Questions

Each XML element becomes a JSON key, its text becomes the value, and nested elements become nested objects. Elements that repeat with the same name are grouped into an array.
Attributes are kept as keys prefixed with @, so <book id="7"> becomes "@id": "7". If an element has both attributes and text, the text is stored under the key "#text".
XML has no data types; everything is text. The converter keeps values as strings to avoid guessing incorrectly, so convert numbers and booleans in your code if needed.
An element that appears once is converted to a single value or object, while one that repeats becomes an array. If your code always expects an array, normalise the data after conversion.
Yes. Paste the feed or sitemap XML and convert it to get the items as a JSON array, which is easier to work with in JavaScript.
No. The browser's built-in parser reads the XML and the conversion happens on your device.