RSS feeds are a classic way to keep up-to-date with new content from various sources. If you’ve ever wanted to create an RSS feed reader using TypeScript, you’ll be happy to know that with modern tools like axios and xml2js, it’s easier than ever. In this post, I’ll guide you step-by-step through creating an RSS feed reader that fetches and parses feeds directly from any source URL.
Thank me by sharing on Twitter 🙏
By the end of this guide, you’ll have a clear understanding of how to set up axios for HTTP requests and use xml2js to convert XML into a manageable JavaScript object.
etguuds USB to USB C Cable 3ft, 2-Pack USB A to Type C Charger Cord Fast Charging for Samsung Galaxy A17 A16 A15 A26 A36 A56, S25 S24 S23 S22 S21 S20 S10 Note 20, for iPhone 17 16 15, Moto, Gray
$5.59 (as of November 28, 2025 01:44 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)The Art and Making of Arcane (Gaming)
$34.35 (as of November 26, 2025 18:35 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)HP 67XL Black High-Yield Ink Cartridge Printers | Works with Printer Series: DeskJet 1255, 2700, 4100, Envy 6000, 6400 Series | Eligible for Instant Ink | 3YM57AN
$35.89 (as of November 28, 2025 01:44 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Why Use Axios and xml2js?
You might be wondering why I chose axios and xml2js for this project. The reason is simple: axios is a robust library for making HTTP requests, and xml2js is a powerful XML parser that converts XML content into JSON. Together, they provide an easy-to-use solution for working with RSS feeds in TypeScript.
Setting Up the Project Dependencies
Before we start coding, you’ll need to install axios and xml2js:
npm install axios xml2jsWith these installed, we’re ready to build our TypeScript RSS feed reader.
Anker USB C to USB C Cable (6FT, 2Pack), Type-C 100W Charger Cord Fast Charging for iPhone 17 Series,MacBook Pro 2020,Pixel and More(Black)
$12.99 (as of November 28, 2025 01:44 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Frictionless: 7 Steps to Remove Barriers, Unlock Value, and Outpace Your Competition in the AI Era
$0.99 (as of November 26, 2025 18:35 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Apple 240W USB-C to USB-C Woven Charge Cable (2 m): Fast and Convenient Charging
$18.00 (as of November 28, 2025 01:44 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Fetching and Parsing RSS Feeds with Axios
To fetch and parse RSS feeds, I break the process into two main parts: fetching the data and converting it from XML to a JSON structure. Here’s how to do it step-by-step.
Fetching RSS Feed Data
Fetching data from a URL using axios is straightforward. It handles HTTP requests and returns a Promise that resolves to the response. In our RSS feed reader, we’ll use axios.get() to request data from a feed URL:
import axios from 'axios';
async function fetchRssFeed(url: string): Promise<string> {
try {
const response = await axios.get(url, { responseType: 'text' });
return response.data;
} catch (error) {
console.error('Error fetching the RSS feed:', error);
throw new Error('Failed to fetch RSS feed');
}
}In this function, we use axios.get() to fetch data and set responseType to text to ensure we receive a raw string (XML format). If there’s an error during the request, we catch and log it.
Parsing XML Data with xml2js
After fetching the XML, we need to convert it to a format we can work with—like JSON. That’s where xml2js comes in. The parseStringPromise function from xml2js allows us to convert the XML data into a JavaScript object.
Here’s how to parse the XML:
import { parseStringPromise } from 'xml2js';
async function parseRssFeed(xml: string): Promise<any> {
try {
const result = await parseStringPromise(xml);
return result;
} catch (error) {
console.error('Error parsing the RSS feed:', error);
throw new Error('Failed to parse RSS feed');
}
}Extracting and Structuring Feed Data
The parsed data from xml2js is often nested and needs a bit of handling to extract the content properly. To make it easier to work with, we should map the data to a structured format with only the properties we need.
interface FeedItem {
title: string;
link: string;
pubDate: string;
description?: string;
}
async function extractFeedItems(parsedData: any): Promise<FeedItem[]> {
const items = parsedData.rss.channel[0].item.map((item: any) => ({
title: item.title[0],
link: item.link[0],
pubDate: item.pubDate[0],
description: item.description[0]
}));
return items;
}In this function, we assume the structure of the parsed XML data is standard for an RSS feed (rss.channel[0].item). We map the data to an array of FeedItem objects, extracting only the title, link, pubDate, and description.
Bringing It All Together
Now that we have functions to fetch, parse, and structure our feed data, let’s combine them into a main function that ties everything together and logs the feed items:
async function fetchAndDisplayRssFeed(url: string): Promise<void> {
try {
const xmlData = await fetchRssFeed(url);
const parsedData = await parseRssFeed(xmlData);
const feedItems = await extractFeedItems(parsedData);
console.log('RSS Feed Items:');
feedItems.forEach((item, index) => {
console.log(`${index + 1}. ${item.title}`);
console.log(` Link: ${item.link}`);
console.log(` Published: ${item.pubDate}`);
console.log(` Description: ${item.description || 'No description available'}`);
});
} catch (error) {
console.error('Error during RSS feed processing:', error);
}
}
// Example usage:
const rssUrl = 'https://example.com/rss';
fetchAndDisplayRssFeed(rssUrl);Conclusion
Building an RSS feed reader using TypeScript, axios, and xml2js is a manageable task once you break it down into clear steps. We first fetched the RSS feed data using axios, parsed it into a JSON format with xml2js, and then structured the content to make it easy to display.
This approach not only helps you understand how to work with external data sources in TypeScript but also highlights the flexibility you have when integrating HTTP requests and XML parsing libraries. With these skills, you can extend your reader to include additional features like feed filtering, user preferences, and more.
RSS feed readers may be old-school, but they remain a powerful way to aggregate and view content across the web efficiently.


