Skip to content

Instantly share code, notes, and snippets.

@astrolemonade
Forked from evdokimovm/index.js
Created March 11, 2026 20:45
Show Gist options
  • Select an option

  • Save astrolemonade/570e7957912e5f1add19392f57461a75 to your computer and use it in GitHub Desktop.

Select an option

Save astrolemonade/570e7957912e5f1add19392f57461a75 to your computer and use it in GitHub Desktop.
Save the whole list of your saved youtube playlists to text file. Open youtube.com/feed/library or youtube.com/feed/you press "show more" in playlists section. scroll page down to load all playlists list and run the following script in console

Export all your saved YouTube playlists

⚠️ The script is updated and works again in 2026 ⚠️

Since Google Takeout for YouTube doesn't export playlists you've saved, but only those you've created, I've written this script that will automatically export the list of saved playlists to a text file


If you want the export to be produced in CSV format, then change the value of the format variable (line 9) to .csv


Export saved playlists:

  1. Open youtube.com/feed/playlists

  1. ❗ Press the "Saved" button at the top to see only the playlists you've saved so far ❗ SCREENSHOT

  1. Scroll down the page to the bottom to ensure that all playlists are loaded and displayed
  2. Open JS console
  3. Paste and run the script

Export the contents of a specific playlist:

Also, you can export the contents of a specific playlist to a text file. To do this:

  1. Open playlist you want to export. Your likes for example: https://www.youtube.com/playlist?list=LL
  2. Scroll down the page to the bottom to ensure that all contents are loaded and displayed
  3. Open JS console
  4. Paste and run the script
var saving_playlist = window.location.href.includes('/playlist?list=')
var all_contents =
saving_playlist ?
document.querySelectorAll('div#contents > ytd-playlist-video-renderer > div#content > div#container > div#meta')
:
document.querySelectorAll("#content > yt-lockup-view-model > div > div > yt-lockup-metadata-view-model")
var format = '.txt'
async function get_title(item) {
return item.querySelector('h3 > a').innerText
}
async function get_link(item) {
if (!saving_playlist) {
return item.querySelector('div > yt-content-metadata-view-model > div:last-child > span > span > a').href
} else {
return item.querySelector('h3 > a').href
}
}
async function get_channel_name(item) {
if (!saving_playlist) {
return item.querySelector('div > yt-content-metadata-view-model > div:nth-of-type(1) > span').innerText
} else {
return item.querySelector('ytd-video-meta-block > div#metadata > div#byline-container > ytd-channel-name').innerText.trim() || "no data available"
}
}
async function get_channel_link(item) {
if (!saving_playlist) {
return item.querySelector('div > yt-content-metadata-view-model > div:nth-of-type(1) > span > span > a').href
} else {
return item.querySelector('div > ytd-video-meta-block > div#metadata > div#byline-container > ytd-channel-name#channel-name > div#container > div#text-container > yt-formatted-string > a')?.href.trim() || "no data available"
}
}
async function get_data(item) {
var data = {
title: await get_title(item),
channel_name: await get_channel_name(item),
channel_link: await get_channel_link(item),
link: await get_link(item)
}
return data
}
async function concatenate(data, format) {
if (format == '.csv') {
return `"${data.title}","${data.channel_name}","${data.channel_link}","${data.link}"\n`
}
return `${data.title} | -> ${data.channel_name} | -> ${data.channel_link}\n${data.link}\n\n`
}
async function put_things_together(format) {
var list = (format == '.csv') ? `"Title","Channel Name","Channel Link","Link"\n` : ''
var data = ''
for (var i = 0; i < all_contents.length; i++) {
data = await get_data(all_contents[i])
list += await concatenate(data, format)
}
return list
}
var list = await put_things_together(format)
function download(filename, text) {
var blob = new Blob([text], { type: 'text/plain' })
var url = URL.createObjectURL(blob)
var link = document.createElement('a')
link.href = url
link.download = filename
link.click()
URL.revokeObjectURL(url)
}
download('my_youtube_saved_playlists' + format, list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment