๐Ÿ”’ Runs in your browser โ€” nothing is uploadedโœ“ Free, no signup

XML to JSON Converter

Convert XML into clean JSON. Attributes, text content and repeated elements are kept, and numbers and booleans can be converted to real JSON types.

Loading...

0 characters

JSON

Loading...

When should you use the XML to JSON Converter?

  • Working with an XML or SOAP API from JavaScript
  • Converting an RSS feed or XML export into JSON
  • Migrating XML config files to JSON

How to use the XML to JSON Converter

  1. 1

    Paste XML

    Paste your XML into the left editor, or click Load sample.

  2. 2

    Choose how attributes look

    Attributes become keys with a prefix such as @_id, so they don't clash with child elements.

  3. 3

    Set value types

    Keep 'Convert numbers & booleans' on to turn 42 and true into real JSON types.

  4. 4

    Copy or download

    Copy the JSON or download it as a .json file.

Examples

Attributes and repeated elements

XML

<book id="1">
  <title>XML Guide</title>
  <tag>xml</tag>
  <tag>json</tag>
</book>

JSON

{
  "book": {
    "title": "XML Guide",
    "tag": ["xml", "json"],
    "@_id": 1
  }
}

Common errors and how to fix them

A single item isn't an array
XML doesn't say whether an element can repeat, so one <tag> becomes a value and two or more become an array. Check for both cases in your code.
Leading zeros disappeared
Values like 007 were converted to numbers. Untick 'Convert numbers & booleans' to keep every value as text.
Related tools:ย JSON to XML Converter ยท XML Formatter ยท JSON Formatter

More from JSON Tools

Free tools that run in your browser โ€” no signup, nothing uploaded.

XML to JSON Converter FAQ

Each attribute becomes a key with a prefix โ€” @_ by default โ€” next to the element's children, so <book id="1"> becomes "@_id": 1. You can change or remove the prefix.

Repeated elements with the same name become a JSON array. An element that appears only once stays a single value.

When an element has both attributes and text, the text is stored under #text, for example <price currency="USD">9.99</price> becomes { "#text": 9.99, "@_currency": "USD" }.

Yes โ€” they're XML, so any well-formed SOAP envelope or RSS feed converts. Namespaced tags keep their prefix, like soap:Body.

Yes. If the XML isn't well-formed you'll get the line and column of the error instead of a partial result.

No. Conversion happens in your browser.