# How do I export YouTube comments to CSV or Excel?

> Export the comments on a YouTube video to a CSV that opens cleanly in Excel: text, author, likes, reply counts and dates. Cost per 1,000 comments and a Python script.

Canonical page: https://okdata.online/answers/export-youtube-comments-csv/

**Short answer: **Page through YouTube video comments (/v1/youtube/videos/comments/list) and write each comment to a CSV row: $0.004 per page of about 20 comments, so 1,000 comments cost $0.20. Each row gets the text, author, likes, reply count and date; save as UTF-8 with BOM so Excel shows emoji and accents.

Your product review video went up last week and has 3,000 comments. The marketing lead wants them in a spreadsheet by tomorrow, sorted by likes, so the team can tag complaints and feature requests. Copying from the page is hopeless past a few dozen. A short script does it in a couple of minutes.

## The endpoint

[YouTube video comments](/apis/youtube/videos/comments/list/) takes the video `id` and `sort` (`top` or `latest`) and returns about 20 comments per call, each with `text`, `author`, `likes`, `replies` and `published_at`. Pass `page.next_cursor` back as `cursor` until `page.has_more` is false.

## The script

```python
import csv, os, requests

API = "https://api.okdata.online/v1/youtube/videos/comments/list"
H = {"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"}
VIDEO = "dQw4w9WgXcQ"   # the v= part of the link
MAX_PAGES = 150         # about 3,000 comments

rows, cursor = [], None
for _ in range(MAX_PAGES):
    params = {"id": VIDEO, "sort": "top", **({"cursor": cursor} if cursor else {})}
    body = requests.get(API, headers=H, params=params, timeout=60).json()
    if body["code"] != "ok":
        raise RuntimeError(f"{body['code']}: {body['message']}")
    for c in body["data"]["items"]:
        rows.append([c["id"], c["published_at"], c["author"]["name"], c["likes"], c["replies"], c["text"]])
    if not body["page"]["has_more"]:
        break
    cursor = body["page"]["next_cursor"]

with open(f"{VIDEO}-comments.csv", "w", newline="", encoding="utf-8-sig") as f:
    w = csv.writer(f)
    w.writerow(["comment_id", "published_at", "author", "likes", "replies", "text"])
    w.writerows(rows)
print(len(rows), "comments saved")
```

`utf-8-sig` writes a byte-order mark, which is what makes Excel open the file with emoji and non-English text intact. The `csv` module quotes commas and line breaks inside comments for you.

## Cost

| Video size | Calls | Cost |
|---|---|---|
| 500 comments | 25 | $0.10 |
| 1,000 comments | 50 | $0.20 |
| 3,000 comments | 150 | $0.60 |

You pay per page actually fetched. Stop early with `MAX_PAGES` and the bill stops there too.

## What the sheet will not have

- **Reply threads.** You get top-level comments with a reply count, not the replies themselves.
- **Exact old dates.** Dates can be worked out from YouTube labels such as 2 months ago, so older comments are approximate.
- **Commenter location.** YouTube does not show it; the field is null.

## Other ways to do it

- **Official YouTube Data API.** `commentThreads.list` costs 1 quota unit per call and includes some replies; with a Google key and a modest volume it is free and the better choice.
- **youtube-comment-downloader.** An open-source command-line tool, good for a one-off export if it works from your network; its issues include a recipe for turning the output into Excel.
- **By hand.** Under 50 comments, copy and paste is fine.

To read what the comments say at scale, see the [word-of-mouth solution page](/solutions/word-of-mouth/).

## Endpoints used

- [YouTube video comments](https://okdata.online/apis/youtube/videos/comments/list/) `youtube.videos.comments.list`: $0.004 per call · about 20 comments per page

Updated 2026-11-12
