Tools

XML to JSON converter

Turn XML — RSS feeds, sitemaps, SOAP responses, Maven POMs — into JSON and back, with attributes kept under a prefix you choose.

Runs in your browserData formats3.1K
Free

Input

0 B

Result

The result will appear here.

XML is still what RSS and Atom feeds, sitemaps, SOAP services and Maven builds speak, and most code that consumes it would rather have JSON. This converts in both directions with fast-xml-parser, a dependency-free parser used widely across the Node ecosystem. The document is validated first, so a missing closing tag is reported with its line and column instead of producing half a result. Attributes land under a prefix, @_ by default, so they never collide with child elements of the same name, and text is kept as strings unless you ask for numbers and booleans to be parsed.

How it works

  • Repeated sibling elements, such as the <item>s of an RSS channel, become a JSON array; a single one stays an object.
  • An element with both attributes and text gets its text under #text, next to the prefixed attributes.
  • Typed values are off by default, so <version>2.10</version> stays "2.10" instead of becoming the number 2.1.
  • Going to XML, the JSON needs exactly one top-level key, which becomes the root element.

Where your data goes

Nowhere. This tool runs entirely in your browser: the text you paste is processed by the page and is never transmitted to a server or written to a log.

This tool is free and needs no account. Its results exist only in your open page and are not saved anywhere.

What it costs

This tool is free, with no sign-in and no points.

Common questions

Why is one <item> an object but two are an array?
XML itself does not say whether an element can repeat; only a schema does. With a single <item> the converter has no reason to create an array. If your code expects an array every time, normalise after converting, for example with [].concat(channel.item).
What does the @_ prefix mean?
It marks keys that came from attributes rather than child elements, so <guid isPermaLink="true"> becomes "@_isPermaLink": "true". Pick @ or $ to match what your code already uses. The same prefix tells the JSON to XML direction which keys to write back as attributes.
What happens to namespaces, comments and CDATA?
Namespace prefixes are kept as part of the name, so atom:link stays atom:link. Comments are dropped, and CDATA sections are read as ordinary text. The XML declaration and processing instructions are skipped, since they carry no data.
Is it safe to paste XML from an untrusted source?
Yes. fast-xml-parser never fetches external entities or DTDs, so the classic XXE attacks have nothing to reach, and the conversion runs inside this page without sending the document anywhere.

The open-source behind it

This tool runs on NaturalIntelligence/fast-xml-parser, released under MIT. If you need the same behaviour inside your own program, that is the library to reach for.

NaturalIntelligence/fast-xml-parser

Also known as

  • xml to json
  • json to xml
  • xml converter online
  • rss to json
  • xml parser
  • convert xml to json javascript