ToolFeather
Developer / SEORuns in your browser

XML to JSON Converter

Paste XML or open a file and get clean, predictable JSON: attributes are kept as @keys, repeated elements turn into arrays, and numbers and booleans come out as real JSON types.

Quick presets

XML to JSON Converter

XML
JSON

Runs in your browser — nothing you enter is uploaded or stored.

ToolFeather · XML → JSON
Scratchpad auto-saved
Stored in this browser (localStorage)
Step-by-step~40s read

How it works — in four simple steps

No signup and nothing to install — it all runs in your browser.

1

Add your XML

Paste it into the left box, press Open file, or drag a .xml file onto it. Sample loads a realistic example.

2

Set the options

Adjust the options above the boxes — the output updates instantly as you change them.

3

Check the result

Read the status line: it reports rows, keys and any value that couldn't be represented in JSON.

4

Copy or download

Copy the JSON or download it as a .json file. Nothing was uploaded at any point.

Pro tip

Feeding the JSON to code? Tick Always make arrays so a list with a single entry still comes out as an array.

Features

Attributes kept, clearly marked

XML attributes become keys with an @ prefix (or _ / - / none), so they never collide with child elements of the same name.

Real types, not just strings

Numbers, booleans and empty values are detected — while codes with leading zeros such as 00742 or +44 phone numbers stay text.

Namespace control

Keep prefixes like dc:title, or strip them to get plain keys when the namespaces don't matter to you.

Stable array shape

Optionally make every child element an array, so code doesn't break when a list happens to have only one entry.

Pretty or minified

2 or 4 spaces, tabs, or a minified single line for the smallest possible file.

Private by design

Parsing and conversion run in your browser with JavaScript — your data is never uploaded, logged or stored.

About the XML to JSON Converter

XML and JSON both describe trees, but they disagree on the details. XML has attributes and mixed text; JSON has neither. XML can repeat an element name any number of times; JSON keys must be unique. XML has no data types at all — <year>1988</year> is just text — while JSON distinguishes 1988 from "1988". Any XML-to-JSON converter has to pick a convention for each of these, and the choice decides whether the JSON is pleasant to use.

This converter uses the convention most libraries settled on (it matches the default of popular parsers such as fast-xml-parser and xmltodict): each element becomes a key; attributes become keys with an @ prefix; when an element has attributes and text, the text goes into #text; and when the same child name appears more than once, the values are collected into an array in document order. Comments and processing instructions are dropped, CDATA is read as ordinary text, and entity references like &amp; are decoded.

The one convention that bites people is the array rule: a <book> that appears twice becomes an array, but if it appears once it's a plain object — so code that does data.store.book.forEach breaks on a store with one book. Tick Always make arrays when you're feeding the JSON to code and need a stable shape. The XML is parsed by your browser's own standards-compliant parser, so a malformed document is reported with the parser's message instead of being silently half-converted.

Examples

An RSS 2.0 feed is the classic real-world case: a channel with metadata, a namespaced author field, and a list of repeated <item> elements with attributes.

XML input
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>ToolFeather Blog</title>
    <link>https://toolfeather.com/blog/</link>
    <item>
      <title>How to convert XML to JSON</title>
      <guid isPermaLink="false">post-101</guid>
      <dc:creator>Pratik</dc:creator>
      <pubDate>Tue, 20 Oct 2026 09:00:00 GMT</pubDate>
    </item>
    <item>
      <title>CSV quoting rules explained</title>
      <guid isPermaLink="false">post-102</guid>
      <dc:creator>Pratik</dc:creator>
      <pubDate>Mon, 19 Oct 2026 09:00:00 GMT</pubDate>
    </item>
  </channel>
</rss>
JSON output
{
  "rss": {
    "@version": 2,
    "channel": {
      "title": "ToolFeather Blog",
      "link": "https://toolfeather.com/blog/",
      "item": [
        {
          "title": "How to convert XML to JSON",
          "guid": {
            "@isPermaLink": false,
            "#text": "post-101"
          },
          "creator": "Pratik",
          "pubDate": "Tue, 20 Oct 2026 09:00:00 GMT"
        },
        {
          "title": "CSV quoting rules explained",
          "guid": {
            "@isPermaLink": false,
            "#text": "post-102"
          },
          "creator": "Pratik",
          "pubDate": "Mon, 19 Oct 2026 09:00:00 GMT"
        }
      ]
    }
  }
}

This output was produced by the converter on this page with Strip namespace prefixes switched on — load it with the “RSS feed” preset above and change any option to see the effect.

How XML maps to JSON

In XMLBecomes in JSON
<title>Dune</title>"title": "Dune"
Attribute id="7""@id": 7 (prefix is configurable)
Text next to attributes <price cur="USD">9</price>"price": {"@cur": "USD", "#text": 9}
Two or more <item> siblings"item": [ … ] in document order
Empty element <note/>"note": ""
<![CDATA[a < b]]>the plain string "a < b"
Namespace prefix dc:creatorkept as "dc:creator", or "creator" with Strip namespaces
Comments and <?xml?>dropped — JSON has no place for them

Things that trip people up

XML vs JSON at a glance

PropertyXMLJSON
SpecificationXML 1.0 Fifth Edition (W3C, 2008)RFC 8259 (2017) · ECMA-404
File extension.xml.json
Media typeapplication/xml (RFC 7303)application/json
Data typestext only (types come from a schema)string, number, boolean, null, object, array
CommentsYes <!-- -->No
NestingUnlimitedUnlimited

Frequently asked questions

5 answers
How are XML attributes converted to JSON?
Each attribute becomes a key on the element's object with an @ prefix — <book isbn="123"> gives {"@isbn": 123}. You can switch the prefix to _ or -, or remove it, in the options.
Why is one element an object and another an array?
Repeated sibling elements are collected into an array; a single one stays an object. Tick Always make arrays to get arrays everywhere, which is safer when the JSON feeds code.
Can it convert an RSS feed or a sitemap.xml?
Yes. RSS items, Atom entries and sitemap <url> entries are repeated elements, so they come out as arrays you can loop over. Use Strip namespace prefixes for feeds that use dc: or media: tags.
Does it validate my XML?
It checks well-formedness with your browser's XML parser and shows the error if a tag isn't closed or an attribute isn't quoted. It doesn't validate against an XSD or DTD — use the XML Validator for line-by-line diagnostics.
Is my data uploaded anywhere?
No. The XML is parsed and converted by JavaScript in your browser tab; nothing is sent to a server, so it is safe for internal exports, customer lists and configuration files with secrets.