Tutorial
How to Export YouTube Comments to CSV
Download public YouTube comments and replies to CSV for audience research, sentiment analysis, content planning, and AI workflows.
Written by Alex P.
- export youtube comments to csv
- download youtube comments
- youtube comments excel
- youtube comment analysis
- youtube comments API
Exporting YouTube comments to CSV gives you a structured view of an audience conversation. Instead of reading one comment thread at a time, you can filter questions, compare recurring themes, sort by engagement, and keep the source feedback beside your analysis.
FetchLayer provides three ways to create the export:
- Use FetchLayer Research Chat to retrieve the comments, analyze them with AI, and download CSV or JSON without writing code.
- Use the YouTube Comments API to fetch structured comments and build the export inside your own application or automation.
- Connect FetchLayer MCP to Claude, Codex, Hermes, or another compatible AI client and let your own agent create the analysis and export.
Use Research Chat for a fast one-off analysis. Use the API for scheduled collection, multiple videos, custom schemas, and repeatable research pipelines.
To retrieve the raw conversation first, start with the YouTube Comments API or read how to get YouTube comments through an API.
For JavaScript and TypeScript developers, the official @fetchlayer/youtube npm package wraps the endpoint with typed responses. It is open source on GitHub.
What should a YouTube comments CSV include?
The minimum useful schema preserves each comment and its source context:
| Column | Why it matters |
|---|---|
username | Keeps the public author name attached to the feedback |
comment | Contains the full comment text |
likes | Provides a simple engagement signal |
date | Shows the relative date presented with the comment |
is_reply | Distinguishes top-level comments from replies |
parent_comment | Preserves thread context for a reply |
video_url | Connects the row to its source video |
retrieved_at | Records when the export was collected |
For analysis, add columns such as theme, sentiment, question, pain_point, content_request, or priority. Keep the original comment text even after adding AI classifications so a researcher can verify the evidence.
Method 1: Export YouTube comments with AI and no code
In FetchLayer Research Chat, provide the public video URL and describe the analysis you want. The chat can retrieve the visible comments and replies, organize the discussion, and write the result to a downloadable file.
A useful starting prompt is:
Analyze the comments on this YouTube video. Find recurring questions, pain points, and requests for future content. Export a CSV with the username, comment, likes, date, theme, and sentiment.
You can then refine the same export through follow-up messages:
- Keep only comments that contain a question.
- Rank content requests by how often they appear.
- Add representative quotes for every theme.
- Separate product objections from tutorial requests.
- Include replies and keep their parent-comment context.
- Convert the current artifact to CSV.
The downloadable artifact contains the structured rows. The chat response can stay focused on the most important findings instead of dumping the full comment dataset into a message.
Open YouTube comment analysis in Research Chat
Method 2: Retrieve comments through the API
Send a public YouTube video URL to the comments endpoint:
curl -X POST https://api.fetchlayer.dev/youtube/comments \
-H "Authorization: Bearer ss-your-key" \
-H "Content-Type: application/json" \
-d '{
"videoUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"sort": "top",
"pages": 2
}'
Use top to focus on the most engaged comments. Use newest when you are studying the latest response to a video, launch, announcement, or event. Use the /comments/replies endpoint to load reply threads for comments where the discussion matters most.
Convert YouTube comment JSON to CSV in JavaScript
The comments endpoint returns top-level comments. Use the /comments/replies endpoint to load reply threads for comments where the discussion matters:
const videoUrl = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
const response = await fetch('https://api.fetchlayer.dev/youtube/comments', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.FETCHLAYER_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ videoUrl, sort: 'top', pages: 2 }),
});
if (!response.ok) throw new Error(`FetchLayer returned ${response.status}`);
const comments = await response.json();
// For comments with replies, fetch the thread
const rows = [];
for (const comment of comments) {
rows.push({
username: comment.username,
comment: comment.comment,
likes: comment.likes,
date: comment.date,
is_reply: false,
parent_comment: '',
video_url: videoUrl,
});
if (comment.hasReplies) {
const repliesRes = await fetch('https://api.fetchlayer.dev/youtube/comments/replies', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.FETCHLAYER_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ videoUrl, commentId: comment.id }),
});
if (repliesRes.ok) {
const thread = await repliesRes.json();
for (const reply of (thread.nestedReplies ?? [])) {
rows.push({
username: reply.username,
comment: reply.comment,
likes: reply.likes,
date: reply.date,
is_reply: true,
parent_comment: comment.comment,
video_url: videoUrl,
});
}
}
}
}
const columns = ['username', 'comment', 'likes', 'date', 'is_reply', 'parent_comment', 'video_url'];
const escapeCsv = (value) => `"${String(value ?? '').replaceAll('"', '""')}"`;
const csv = [
columns.join(','),
...rows.map((row) => columns.map((column) => escapeCsv(row[column])).join(',')),
].join('\n');
await Bun.write('youtube-comments.csv', csv);
For Node.js, write the same csv string with node:fs/promises. For large datasets or complex schemas, use a CSV library that supports streaming and explicit column definitions.
Open YouTube comments in Excel or Google Sheets
CSV files can be imported into Excel, Google Sheets, Numbers, or another spreadsheet tool. Correct escaping matters because comments regularly contain commas, quotation marks, emoji, and line breaks.
Once imported, you can:
- Filter rows that contain a question mark.
- Sort comments by like count.
- Compare top-level comments and replies.
- Count repeated themes with a pivot table.
- Review negative or confused comments separately.
- Create a prioritized list of future video ideas.
Use UTF-8 when saving the file so usernames, emoji, and non-English comments remain intact.
Export comments for sentiment analysis
Positive, negative, and neutral labels are only a starting point. For useful YouTube comment sentiment analysis, classify the reason behind the sentiment as well.
For example, a negative comment might be:
- Confused by the explanation
- Disappointed by a missing feature
- Objecting to the price
- Reporting a technical problem
- Disagreeing with the conclusion
Those categories point to different actions. Keep a confidence score and the original comment beside every AI-generated label. See how to analyze YouTube comments with AI for a workflow focused on themes and evidence.
Export comments from multiple videos
Use the same schema for every video and include video_url, video_title, or your own campaign identifier. Consistent columns make it easier to combine files and compare audience response across a channel, competitor set, product launch, or content series.
Do not treat public comments as a complete representation of every viewer. Commenters are self-selecting, moderation affects what remains visible, and highly engaged opinions can be overrepresented. Use comment exports as qualitative evidence alongside retention, watch-time, survey, or customer data when available.
Method 3: Use your own AI agent through MCP
Use Research Chat when you want a fast no-code answer. Use FetchLayer MCP when you would rather work in Claude, Codex, Hermes, or another MCP-compatible AI client. Your agent can retrieve comments and replies directly, apply your own research framework, and write the CSV into the workflow you already use.
For example:
Retrieve comments and replies for this YouTube video. Find repeated setup questions, product objections, and requests for future content. Keep representative comments as evidence, then export the comment-level analysis as CSV.
Connect your MCP client to FetchLayer to use the same public-comment retrieval layer without moving your work into another AI tool.