Free XML to JSON Converter Online

Paste your XML document below to get a JSON object your JavaScript, Python, or Node.js code can work with directly, no manual DOM parsing required.

Input Ready

Input statistics are available via the Stats button above this field.

Output

Output statistics are available via the Stats button above this field.

Results are provided for informational purposes only and may contain errors. Please verify important information independently. Use of this tool is at your own risk.

What the XML to JSON Converter does

The XML to JSON Converter parses an XML document and outputs the same data as indented JSON. Elements become keys, attributes become keys prefixed with @_, and repeated elements with the same name become an array.

The XML declaration (<?xml ...?>) is ignored. Text that looks like a number, such as 9.99, is returned as a JSON number rather than a string.

When to use it

  • Working with an RSS feed, sitemap, SOAP response or configuration file in JavaScript, where JSON is easier to handle.
  • Moving data from an XML-based system into a JSON API or a document database.
  • Inspecting a large XML file: the JSON output is often easier to scan, especially after formatting.

Worked example

Input

<catalog>
  <book id="b1"><title>Dune</title><price>9.99</price></book>
  <book id="b2"><title>Emma</title><price>4.5</price></book>
</catalog>

Output

{
  "catalog": {
    "book": [
      {
        "title": "Dune",
        "price": "9.99",
        "@_id": "b1"
      },
      {
        "title": "Emma",
        "price": "4.5",
        "@_id": "b2"
      }
    ],
    "#text": "\n  \n  \n"
  }
}

Common questions about the XML to JSON Converter

Why are some keys prefixed with @_?

Those are XML attributes. The prefix keeps them apart from child elements that may have the same name. The JSON to XML Converter turns them back into attributes.

Why is one element an array and another an object?

An element that appears several times under the same parent becomes an array. An element that appears only once stays a single object. If your code always expects an array, check for this case.

What if my XML is invalid?

Conversion stops with an error. Use Check & Suggest Fix or the XML Validator to find unclosed tags, unquoted attributes or a missing root element.

Frequently Asked Questions

What happens to XML attributes?

Attributes are kept as JSON properties prefixed with @_ (e.g. an id="5" attribute becomes "@_id": "5"), so no information is silently dropped.

Does it handle XML namespaces?

Namespaced tags are parsed as literal element names (e.g. soap:Envelope stays as a single key); this covers the vast majority of real-world XML/SOAP payloads.

Is this tool free?

Yes, it's free to use. No signup, no email required. Get results on this page.

How do I get my result?

Use the tool on this page. Your result appears here; no email delivery is required.