Get YouTube Transcripts from the Command Line

Recently we just published a piece on how you can download YouTube Transcripts with the YouTube-Transcript-API in Python. Did you know that you can also use the YouTube-Transcript-API to get transcripts via your command line? In this post, we’ll go over how you can use a Python library to download YouTube transcripts via the command line.


In this post we’ll go over:

  • How to Get a YouTube Transcript in the Command Line
    • Example Structure of a YouTube Transcript
  • How to Get multiple YouTube Transcripts in the Command Line
    • Example Structure Returned for Multiple YouTube Transcripts

How To Get YouTube a Transcript in the Command Line

YouTube-Transcript-API’s command line tool for getting the transcript of a YouTube video is pretty simple to use. All you have to do is use the following line in the command line and you’ll get a JSON transcript of your desired YouTube video. Simply replace the ID I used (sQuFl0PSoXo) with the ID of your desired video. This line sends the transcript to a title.txt file.

youtube_transcript_api sQuFl0PSoXo > title.txt

Example Structure of a YouTube Transcript

Here’s an example of a transcript from a YouTube video. You will get a list of a list of dictionaries. It’s not the ideal return, but that’s the structure from the library. The transcripts will be saved in the first entry of the list as a list of dictionaries. Each dictionary contains three keys: duration, start, and text. Now that you have it saved in a text file, you can access it, manipulate it, and use it in programs from here.

How To Get Multiple YouTube Transcripts in the Command Line

Just like we can use the YouTube-Transcript-API library to download multiple transcripts in Python, we can also get multiple transcripts through the command line. The API provides quite a simple method to get multiple transcripts, all you do is pass in multiple IDs separated by a space. The below command will send the four videos from the how to create an ai content moderator playlist to a transcripts.txt file.

youtube_transcript_api pN3jRihVpGk F_7xepUPH7E d5ib3qjQkwk EfY_GG4cqHM > transcripts.txt

Example Response Format from Getting Multiple YouTube Transcripts

Just like the response from getting one YouTube transcript with the YouTube-Transcript-API command line tool, getting multiple transcripts returns a list of lists. Each inner list contains a list of dictionaries. Each dictionary contains a duration, start, and text key. The end of the output looks like the image below.

Summary of Getting YouTube Transcripts from the Command Line

In this post we went over how to use the YouTube-Transcript-API command line tool to download a single transcript and multiple transcripts. We saw that it’s quite easy to download a YouTube transcript with this tool in the command line. All we have to do is pass some YouTube IDs to get the transcripts.

Learn More

To learn more, feel free to reach out to me @yujian_tang on Twitter, connect with me on LinkedIn, and join our Discord. Remember to follow the blog to stay updated with cool Python projects and ways to level up your Software and Python skills! If you liked this article, please Tweet it, share it on LinkedIn, or tell your friends!

I run this site to help you and others like you find cool projects and practice software skills. If this is helpful for you and you enjoy your ad free site, please help fund this site by donating below! If you can’t donate right now, please think of us next time.

Yujian Tang
Yujian Tang

I started my professional software career interning for IBM in high school after winning ACSL two years in a row. I got into AI/ML in college where I published a first author paper to IEEE Big Data. After college I worked on the AutoML infrastructure at Amazon before leaving to work in startups. I believe I create the highest quality software content so that’s what I’m doing now. Drop a comment to let me know!


Make a one-time donation

Make a monthly donation

Make a yearly donation

Choose an amount


Or enter a custom amount


Your contribution is appreciated.

Your contribution is appreciated.

Your contribution is appreciated.

DonateDonate monthlyDonate yearly

Leave a Reply

%d bloggers like this: