Export YouTube subscriptions into RSS
March 8, 2025 in SoftwareBased 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
- Open the YouTube page for your subscribed channels https://www.youtube.com/feed/channels
- Scroll down the page until all channels are loaded (it will lazy-load them as you scroll to the bottom.)
- Open the Developer Console and run the script
- The OPML file will be generated and prompted as a download.
- 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('"', """).replace(">", ">");
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();
Liked the post? Treat me to a coffee