---
title: "Export a YouTube Playlist to CSV or JSON | FetchTranscript"
description: "Export every video of a YouTube playlist with title, position, duration, views and channel to CSV or JSON, even playlists of thousands of videos, with code."
url: "https://fetchtranscript.com/blog/export-youtube-playlist"
markdown: "https://fetchtranscript.com/blog/export-youtube-playlist.md"
---

YouTube

# How to Export a YouTube Playlist to CSV or JSON

Export every video of a YouTube playlist with title, position, duration, views and channel to CSV or JSON, even playlists of thousands of videos, with code.

By FetchTranscript team Published November 23, 2026 5 min read

To export a YouTube playlist to CSV or JSON, you read the playlist page by page and write one row per video: its position, title, duration, views and channel. With FetchTranscript that is `GET /v1/playlists/{playlist_id}/videos`, up to 100 videos per call, following a cursor until the last page. Below you will find the free alternatives, then complete scripts in Python and JavaScript that export a playlist of any size.

## Find the playlist ID

The playlist ID is the `list=` value of a playlist URL. In `https://www.youtube.com/playlist?list=PLFgquLnL59alCl_2TQvOiD5Vgm1hCaGSI` it is `PLFgquLnL59alCl_2TQvOiD5Vgm1hCaGSI`. Watch URLs carry it too: `watch?v=...&list=PL...` belongs to the same playlist.

Most public playlists start with `PL`. Two kinds cannot be exported: **private playlists** (only the owner can see them) and **Mixes**, the auto-generated radio playlists whose IDs start with `RD`, which are built on the fly for each viewer. Both answer 404 `playlist_unavailable`; an ID that does not exist answers 404 `playlist_not_found`. Neither costs anything.

## Your options

**Copy by hand.** For a 20-video playlist, selecting the page and pasting into a spreadsheet works. Beyond that, YouTube loads the list lazily and the copy gets messy.

**yt-dlp.** `yt-dlp --flat-playlist -J "https://www.youtube.com/playlist?list=PL..."` prints the playlist as JSON without downloading videos. It is free and good for one-off exports on your own machine. On servers, YouTube challenges data-center IPs, and very long playlists take a while.

**YouTube Data API.** `playlistItems.list` returns 50 items per call at 1 quota unit each, so even a 5,000-video playlist fits easily in the default 10,000 daily units. It needs a Google Cloud project and an API key, and each item carries the video ID, title, description, position and upload date, but no duration or view count: those require extra `videos.list` calls, one per 50 videos.

**A hosted API.** FetchTranscript returns duration, views and channel in the same page, up to 100 videos per call, 1 credit per page. A 1,000-video playlist is 10 calls: well within the 100 free calls you get each month.

## What each row contains

Each video in `videos` has these fields:

| Field                        | Meaning                                                     |
| ---------------------------- | ----------------------------------------------------------- |
| `video_id`                   | The 11-character YouTube ID                                 |
| `title`                      | The video title                                             |
| `position`                   | Its place in the playlist, 1 for the first                  |
| `duration`                   | Length in seconds                                           |
| `view_count`                 | Views                                                       |
| `published_time_text`        | Relative date as YouTube shows it, e.g. "2 years ago"       |
| `channel_id`, `channel_name` | The channel that uploaded it (playlists often mix channels) |
| `thumbnail_url`              | A thumbnail image                                           |
| `description`                | Always null in playlists                                    |

Each page also has `total_videos` (the count the playlist shows, null when YouTube hides it), `total_pages` for your `limit`, `has_more` and `next_cursor` (null on the last page). You can see a real answer without an account on the [YouTube Playlist API page](https://fetchtranscript.com/youtube-playlist-api.md).

## Try one page with curl

```bash
curl -H "X-API-Key: yt_your_api_key" \
  "https://api.fetchtranscript.com/v1/playlists/PLFgquLnL59alCl_2TQvOiD5Vgm1hCaGSI/videos?limit=100"
```

To get the next page, add `&cursor=` with the `next_cursor` you received. The cursor is opaque: pass it back unchanged, or the API answers 400 `invalid_parameter`.

## Export to CSV with Python

```python
import csv
import requests

API = "https://api.fetchtranscript.com/v1"
HEADERS = {"X-API-Key": "yt_your_api_key"}

def playlist_videos(playlist_id: str):
    params = {"limit": 100}
    while True:
        r = requests.get(f"{API}/playlists/{playlist_id}/videos", headers=HEADERS, params=params, timeout=60)
        if r.status_code == 404:
            raise SystemExit(r.json()["detail"]["message"])  # not found, private or a Mix
        r.raise_for_status()
        page = r.json()
        yield from page["videos"]
        if not page["has_more"] or not page["next_cursor"]:
            return
        params["cursor"] = page["next_cursor"]

fields = ["position", "video_id", "title", "duration", "view_count",
          "published_time_text", "channel_name", "channel_id"]
with open("playlist.csv", "w", newline="", encoding="utf-8") as f:
    writer = csv.DictWriter(f, fieldnames=fields + ["url"], extrasaction="ignore")
    writer.writeheader()
    for v in playlist_videos("PLFgquLnL59alCl_2TQvOiD5Vgm1hCaGSI"):
        writer.writerow({**v, "url": f"https://www.youtube.com/watch?v={v['video_id']}"})
```

Opening the file in Excel or Google Sheets gives you one row per video, ready to sort by views or sum the durations. A row looks like this (illustrative values):

```csv
position,video_id,title,duration,view_count,published_time_text,channel_name,channel_id,url
1,dQw4w9WgXcQ,Rick Astley - Never Gonna Give You Up (Official Video),213,1600000000,16 years ago,Rick Astley,UCuAXFkgsw1L7xaCfnd5JJOw,https://www.youtube.com/watch?v=dQw4w9WgXcQ
```

With the official SDK (`pip install fetchtranscript`), the pagination loop is one line: `client.playlists.iter_videos(playlist_id, page_size=100)` yields every video, and `max_videos` stops after the first N.

```python
import json
from fetchtranscript import FetchTranscriptClient

client = FetchTranscriptClient(api_key="yt_your_api_key")
videos = list(client.playlists.iter_videos("PLFgquLnL59alCl_2TQvOiD5Vgm1hCaGSI"))
with open("playlist.json", "w", encoding="utf-8") as f:
    json.dump(videos, f, indent=2, ensure_ascii=False)
```

## Export to JSON with JavaScript

```javascript
// Node 18+ as an ES module (a .mjs file, or "type": "module"), for the top-level await
import { writeFile } from 'node:fs/promises';

const API = 'https://api.fetchtranscript.com/v1';
const headers = { 'X-API-Key': 'yt_your_api_key' };

async function playlistVideos(playlistId) {
  const videos = [];
  let cursor = null;
  do {
    const params = new URLSearchParams({ limit: '100' });
    if (cursor) params.set('cursor', cursor);
    const res = await fetch(`${API}/playlists/${playlistId}/videos?${params}`, { headers });
    const page = await res.json();
    if (!res.ok) throw new Error(`${page.detail.error}: ${page.detail.message}`);
    videos.push(...page.videos);
    cursor = page.has_more ? page.next_cursor : null;
  } while (cursor);
  return videos;
}

const videos = await playlistVideos('PLFgquLnL59alCl_2TQvOiD5Vgm1hCaGSI');
await writeFile('playlist.json', JSON.stringify(videos, null, 2));
console.log(`${videos.length} videos exported`);
```

## Very large playlists

Some playlists hold thousands of videos: full lecture archives, music collections, "every episode" lists. Two things matter at that size.

**Speed per page.** Many tools reach page N by reading pages 1 to N-1 again. The cursor here carries YouTube's own continuation, so the 50th page costs the same one request and arrives as fast as the first. Every page costs 1 credit.

**Interruptions.** Save the last `next_cursor` you processed. If the job stops, start again from that cursor instead of from scratch. Rate limits are generous (500 requests per minute), and a 429 answer carries `Retry-After` with the seconds to wait. Failed calls cost nothing; the [errors page](https://fetchtranscript.com/docs/errors.md) lists every code.

## What to do with the export

A playlist export is more than a backup. A few things people commonly compute from it:

- **Total watch time.** Sum `duration` to know how long a course or a "watch later" list really is. A 180-video course at an average of 14 minutes is 42 hours, which is worth knowing before you promise to finish it in a month.
- **What performs.** Sort by `view_count` to see which episodes of a series people actually watch, or compare views by position to spot where an audience drops off.
- **Who contributes.** Playlists built by curators mix channels. Group by `channel_name` to see which creators dominate a list.
- **Broken entries.** Videos that were deleted or made private disappear from the list YouTube shows, so the number of rows can be lower than the positions suggest. Compare the exported positions with yesterday's file to find what vanished.

A few lines of Python do the first two:

```python
import csv

rows = list(csv.DictReader(open("playlist.csv", encoding="utf-8")))
hours = sum(int(r["duration"] or 0) for r in rows) / 3600
top = sorted(rows, key=lambda r: int(r["view_count"] or 0), reverse=True)[:5]
print(f"{len(rows)} videos, {hours:.1f} hours")
for r in top:
    print(r["view_count"], r["title"])
```

Note the `or 0`: a live stream or an unusual entry can come back without a duration or view count, and your code should not crash on it.

## Keeping a playlist in sync

If you export the same playlist regularly, for example to mirror a curated list into your own app, store each run with its date and diff the `video_id` sets: added videos, removed videos and moved positions fall out of a simple comparison. A playlist of a few hundred videos costs a handful of credits per run, so a weekly sync fits easily in the free tier's 100 monthly calls; a daily one uses about that much on its own, and anything beyond is $1 per 1,000 calls. Create a key when you [sign up](https://fetchtranscript.com/auth/sign-up), and see the [API reference](https://fetchtranscript.com/docs/api.md) for every field.

## Exact dates and transcripts

`published_time_text` is relative because that is all a playlist page shows. When you need the exact upload date, likes, tags or the full description, call `GET /v1/videos/{video_id}` for the videos you care about; see [how to get YouTube video metadata](https://fetchtranscript.com/blog/youtube-video-metadata.md).

Playlists are also a natural unit for transcripts: a course, a conference or a podcast season. Loop over the exported IDs and call `GET /v1/transcripts/{video_id}?format=text` for each, as in our guide to [getting all videos from a channel](https://fetchtranscript.com/blog/get-all-videos-from-youtube-channel.md). If you are looking for videos by topic rather than a known playlist, the [YouTube search guide](https://fetchtranscript.com/blog/youtube-search-without-quota.md) is the place to start.

## Frequently asked questions

### Can I export a YouTube playlist to Excel?

Yes. Export it to CSV with the script above and open the file in Excel or Google Sheets; each row is one video with its position, title, duration, views and channel.

### Can I export a private playlist or a Mix?

No. Private playlists are visible only to their owner, and Mixes (IDs starting with `RD`) are generated per viewer; both answer 404 `playlist_unavailable` and cost nothing.

### How many videos can I export?

All of them: the API pages through the playlist 100 videos at a time with a cursor, and every page is as fast as the first, even in playlists of thousands of videos.

### Why is the upload date shown as "2 years ago"?

Playlist pages only show relative dates, so `published_time_text` is what YouTube displays. Use `GET /v1/videos/{video_id}` for the exact `upload_date`.

### How much does it cost to export a playlist?

One credit per page of up to 100 videos. A 1,000-video playlist costs 10 credits, covered by the 100 free calls each month; then it is $1 per 1,000 calls ([pricing](https://fetchtranscript.com/pricing.md)).

Try it on your own videos

100 free calls every month, no credit card. Then $1 per 1,000 calls, only for the calls that succeed.

[Get your free API key](https://fetchtranscript.com/auth/sign-up)[Read the docs](https://fetchtranscript.com/docs.md)

## Related guides

- [How to Get All Videos from a YouTube Channel](https://fetchtranscript.com/blog/get-all-videos-from-youtube-channel.md)

  List every video of a YouTube channel by @handle, page by page with a cursor, export it to CSV, with or without Shorts, and get the transcripts of a channel.

- [How to Get YouTube Video Metadata: Views, Likes, Tags](https://fetchtranscript.com/blog/youtube-video-metadata.md)

  Get the title, description, views, likes, comment count, upload date, tags, categories and chapters of any YouTube video as JSON, with curl, Python or JS.

- [YouTube Search API Without Quota Limits](https://fetchtranscript.com/blog/youtube-search-without-quota.md)

  The YouTube Data API allows about 100 searches a day. How its quota works, what it costs to go beyond it, and how to search YouTube from code without units.

[← All articles](https://fetchtranscript.com/blog.md)
