Map Extract
Free tool

Convert XML to JSON

Paste an order, a product feed, an RSS item or an export from an older system, and get JSON you can feed to a script, a no-code automation or a spreadsheet add-on. Four options control how attributes, values and repeated tags are written.

Runs in your browser. Nothing you enter is uploaded.

Using the converter

  1. Start from an example or your own XML

    The buttons above the box load a product feed item, an RSS item or a short contact list so you can see the shape of the output. Replace it with your own XML whenever you are ready.

  2. Set the attribute prefix

    Attributes are written as keys starting with @ by default. Switch to _ or - if the system you are feeding dislikes @, or to none if you know attribute and tag names never clash.

  3. Decide on typing and arrays

    Tick Detect numbers and true/false to write 4 instead of "4". Tick Always use arrays for child elements if your code expects a list even when there is only one item.

  4. Choose the indent and copy

    Two or four spaces are easy to read; Minified puts everything on one line for pasting into a request or a config field. Copy the result or download it as data.json.

Example: one order from an old ordering system

A small food wholesaler exports each web order as XML and wants to push it into a no-code tool that only accepts JSON. With the default settings every value stays a string, and the <price> tag, which has both an attribute and text, gets a #text key for its value.

With Detect numbers and true/false ticked and Minified chosen, the same order becomes one line, qty turns into the number 4, the price into 18.5 and paid into the boolean false.

Input
<order ref="SO-2207">
  <customer>Hollin Bakery Supplies</customer>
  <line sku="FL-25"><qty>4</qty><price currency="GBP">18.50</price></line>
  <paid>false</paid>
</order>
Result
{
  "order": {
    "@ref": "SO-2207",
    "customer": "Hollin Bakery Supplies",
    "line": {
      "@sku": "FL-25",
      "qty": "4",
      "price": { "@currency": "GBP", "#text": "18.50" }
    },
    "paid": "false"
  }
}

Terms you will meet in the output

Attribute prefix
The character put in front of attribute names so <line sku="FL-25"> gives "@sku" and cannot be confused with a child tag called sku.
#text
The key that holds an element's own text when that element also has attributes or child tags, as with <price currency="GBP">18.50</price>.
Type detection
Turning text that looks like a number or the words true and false into real JSON numbers and booleans. Values with a leading zero, such as phone area codes like 0161 or a code like 007, stay as text so the zero survives.
Always arrays
Writing every child element as a list. Without it, a tag that appears once is an object and a tag that appears twice is a list, which can break code that expects one shape.
CDATA
A section of XML whose content is taken literally. It is unwrapped into a normal string, so <![CDATA[x < y]]> becomes "x < y".

What is dropped on the way

Comments and the <?xml ...?> declaration carry no data, so they do not appear in the JSON. An empty tag such as <fax/> becomes an empty string. If the XML is not well formed, nothing is converted and you see the line number of the first problem, which is usually an unclosed tag or a stray & that should be &amp;.

Questions people ask

How are XML attributes converted to JSON?

Each attribute becomes a key inside the element's object, named with the prefix you choose, so ref="SO-2207" becomes "@ref": "SO-2207" by default. If the element also has text, the text goes under "#text". Choosing no prefix gives shorter keys but can collide with a child tag of the same name.

Why are my numbers in quotes?

XML has no number type: everything between tags is text. The converter keeps it as text unless you tick Detect numbers and true/false. Leave it off when values such as product codes, postcodes or phone numbers might lose a meaningful leading zero or be rounded.

Why is one element an object and another a list?

By default, a tag that appears once in its parent becomes an object, and a tag that appears more than once becomes an array. Tick Always use arrays for child elements to make every child a list, so code that loops over items works the same whether there is one or many.

Can I convert an RSS feed to JSON?

Yes. Save the feed's XML (open the feed URL in your browser and save the page, or copy the source) and paste it here. Each item becomes an object under channel, item, and the RSS example button shows the shape. The converter does not fetch URLs itself.

Where your data goes

The XML is read and converted by script on this page, inside your browser. It is not posted anywhere, so order exports and customer data in the XML stay on your own machine.

Checked against the tool on

Top