Your XML document comes back as plain JSON keyed by element name, with an @ on every attribute and a list for repeated elements.
FluffyShieldProtected workspace
Loading the tool…
The tool didn't load. Reload the page, or check whether an extension or network filter blocks .
Free · No upload · No sign-up · No usage quotas
What happens to the JSON when the feed gets a second episode?
item is an object while there is one episode and a list once there are two. The converter keys the JSON by element name, so read that key as one element or a list.
FluffyBench · 3 min read · Reviewed
From XML to JSON
Read the XML, refusing entity declarations
→Put each element under its name, with attributes marked @
→Collect repeated names into a list in document order
What it does
Numbers stay text
The episode's size, length="18340211", comes out as the text "18340211". Nothing is turned into a number.
Spacing dropped
The same feed laid out over six lines gave the JSON of its one-line form. Whitespace between elements is dropped.
Attributes get an @
The enclosure's attributes become the keys @url, @length, @type, so an attribute can never be mistaken for a child element.
Limits An <!ENTITY> line, or a <!DOCTYPE> with a [ ] part, is refused until it is deleted.
A podcast feed with one episode so far
The bakery's short radio slot now goes out as a podcast, and the website publishes a podcast feed for it: an XML file that podcast apps check for new episodes. XML wraps everything in elements, a name in angle brackets such as <item> with its contents and a closing </item>. An element can also carry attributes, short name and value pairs inside its opening tag, like the address and size of an episode's sound file.
You'd like the feed as JSON, to build a page on your site that lists the episodes. There's one episode so far, so you convert the feed and start writing your page around what comes back.
One episode, then a list
That's where a quick conversion can catch you out. A converter that keys the JSON by element name gives item, a name inside a JSON object, one value. With one episode it is an object. When the second episode arrives, two elements share the name, so the value becomes a list. A page written around the first shape breaks the week episode two goes out.
This converter makes that call: a name used once is an object, and a name used twice is a list in document order. Check whether the channel's item value is an array before looping over it:
One episode, then two
The channel's keys stay title and item. item holds one object with one episode and a list of two once the second arrives. How we checked
The result is compact. Our feed went in as one line of XML and came out as 16 lines of JSON: each element is a key, its attributes are @ keys and its text is a string. To find every episode, read item as one object or a list.
Turning the feed into JSON
Paste the feed into the XML box.
Switch to the Result tab if you're on a phone; the JSON starts with the rss element's key.
Press Download to save the JSON as config-result.json.
Choose 4 spaces from the Indentation list, above the boxes on this page, to put each level further in. The JSON formatter has the same setting for any JSON you paste.
You only want to read the feed, not use it as data