Why convert a feed to JSON
Feeds are XML, and consuming XML in a JavaScript application means either a dependency or a pile of DOM traversal. JSON is what the rest of your code already speaks, so converting at the boundary removes the friction entirely.
The typical uses are small and common: showing recent blog posts on a homepage, aggregating several publications into one internal digest, feeding a status page from a changelog, or pulling podcast episodes into an app.
RSS, Atom, and the inconsistencies between them
RSS 2.0 and Atom describe the same idea with different element names. RSS uses item, pubDate and description; Atom uses entry, published or updated, and summary or content. A consumer that only understands one of them silently returns nothing for the other.
Even inside a single format, publishers differ. Dates appear in at least two conventions. Some feeds put full article HTML in the content field while others include only a truncated summary. Categories may be attributes or child elements. Normalising all of that into one predictable shape is most of the value here.
Fetching feeds from a browser
Most feeds do not send permissive CORS headers, so fetching one directly from browser JavaScript fails regardless of your code being correct. This conversion happens server-side, which sidesteps the restriction.
Cache the result rather than fetching on every page load. Feeds update infrequently, publishers do not appreciate being polled aggressively, and a cached copy is faster for your users anyway.
Frequently asked questions
- Does this support both RSS and Atom?
- Yes. Both are parsed and normalised into the same JSON shape, so your code does not need to care which format the publisher chose.
- Why can I not fetch an RSS feed directly in the browser?
- Most feeds do not send CORS headers, so the browser blocks the request. Converting server-side avoids the restriction entirely.
- Does the JSON include full article content?
- Only if the feed does. Many publishers include just a summary, and no converter can return content the feed never contained.
- How often should I fetch a feed?
- Cache aggressively. Most feeds update a few times a day at most, and polling more often wastes requests and irritates publishers.