Convert XML to JSON

Paste XML from an RSS feed, a sitemap, a SOAP response or a config file and get JSON you can read and use in code. Attributes are kept, and elements that repeat become arrays.

  • Free
  • Runs in your browser
  • Attributes kept
  • No sign-up
How it works

How It Works

Convert XML in three steps.

01

Paste XML

A whole document or a single element with its children.

02

Adjust the mapping

Choose the attribute prefix and whether children are always arrays.

03

Copy or download

Copy the JSON or save it as converted.json.

About

How XML maps to JSON

XML has things JSON lacks, such as attributes and mixed text, so every converter follows a convention. This one uses the common one: an element becomes a key, its attributes become keys starting with @, an element with only text becomes that text, and an element that appears several times under the same parent becomes an array. When an element has both attributes or children and its own text, the text goes under "#text".

Comments and processing instructions are left out, and namespace prefixes stay part of the key (dc:title). The converter goes one way; JSON has no standard way back to attributes.

Attributes

<book id="7"> becomes "book": {"@id": "7", …}. Change the prefix, or clear it, to suit your code.

Consistent arrays

Always use arrays makes every child an array, so code does not break when a feed has one item instead of two.

Optional types

Numbers and true/false can be converted; leading zeros and long numbers stay text.

Safe parsing

Uses the browser's XML parser, which does not fetch external entities or run scripts.

Features

Why Use This Converter

Readable JSON from any XML.

Clear errors

Malformed XML shows the parser's message instead of half a result.

Array control

Choose between compact output and consistent arrays.

Feeds and sitemaps

Handy for RSS, Atom, sitemaps and SOAP responses.

Private

Converted in your browser, nothing uploaded.

✓ No Registration✓ Free✓ Browser-based✓ Text Stays Local
FAQ

Frequently Asked Questions

Questions people ask about the XML to JSON converter.

An element that appears once becomes a single value; one that appears more than once under the same parent becomes an array. Tick Always use arrays for child elements to make every child an array.