🤖🚫 AI-free content. This post is 100% written by a human, as is everything on my blog. Enjoy!

Export YouTube subscriptions into RSS

March 8, 2025 in Software

Based on prior work from https://dhariri.com/2023/youtube-sub-download. 🙇

YouTube has RSS feeds for individual channels, but no RSS feed for your subscriptions. If you’d like to transfer your subscriptions into an RSS reader, this script can generate an OPML file with a list of feeds that you can then import into your reader.

The feeds in the OPML will have the channel feed URL, its web URL, and its name. All feeds are placed into a folder called “YouTube Subscriptions”. й There is no way to specify the channel icons in OPML, but your RSS reader might resolve them from the web URLs. (Reeder does.)

How to run

  1. Open the YouTube page for your subscribed channels https://www.youtube.com/feed/channels
  2. Scroll down the page until all channels are loaded (it will lazy-load them as you scroll to the bottom.)
  3. Open the Developer Console and run the script
  4. The OPML file will be generated and prompted as a download.
  5. Now you can import the file into your RSS reader.

The script

function findChannels(json) {
  if (typeof json != "object") {
    return [];
  }

  if (json.channelId) {
    return [json];
  }

  if (json.flatMap) {
    return json.flatMap(findChannels);
  }

  return Object.values(json).flatMap(findChannels);
}

var opmlData =
  '<?xml version="1.0" encoding="UTF-8"?>\n<opml version="1.0">\n<body>\n<outline text="YouTube Subscriptions" title="YouTube Subscriptions">\n' +
  findChannels(ytInitialData.contents)
    .map((channel) => {
      const channelId = channel.channelId;
      const channelTitle =
        "📺 " + channel.title.simpleText.replace('"', "&quot;").replace(">", "&gt;");
      const channelUrl =
        "https://www.youtube.com" + channel.navigationEndpoint.browseEndpoint.canonicalBaseUrl;
      return [
        "<outline",
        'type="rss"',
        `xmlUrl="https://www.youtube.com/feeds/videos.xml?channel_id=${channelId}"`,
        `htmlUrl="${channelUrl}"`,
        `title="${channelTitle}"`,
        "/>",
      ].join(" ");
    })
    .join("\n") +
  "\n</outline>\n</body>\n</opml>";
var blob = new Blob([opmlData], { type: "text/xml" });
var a = document.createElement("a");
a.href = URL.createObjectURL(blob);
a.download = "subscriptions.opml";
a.click();

Buy me a coffee Liked the post? Treat me to a coffee