Fetch YouTube video and playlist transcripts from the command line.
Install from PyPI:
pypi.org/project/yt-transcript-cli/
pip install yt-transcript-cliOn some systems (especially macOS), pip install may fail or the installed command may not be available on your PATH. This is because modern Python environments restrict installing packages globally to avoid conflicts with system packages.
Use pipx instead, which installs CLI tools in isolated environments:
brew install pipx # macOS
pipx install yt-transcript-clipip install git+https://github.com/kirinmurphy/youtube-transcript-cli.gitOr install locally for development:
git clone https://github.com/kirinmurphy/youtube-transcript-cli.git
cd youtube-transcript-cli
pip install -e .After installation, the yt-transcript-cli command is available.
yt-transcript-cli "https://www.youtube.com/watch?v=VIDEO_ID"yt-transcript-cli "URL1" "URL2" "URL3"yt-transcript-cli "https://www.youtube.com/playlist?list=PLAYLIST_ID"Public and unlisted playlists are supported. Private playlists are not accessible.
yt-transcript-cli -f urls.txtWhere urls.txt contains one URL per line. Lines starting with # are ignored.
yt-transcript-cli -iOr just run with no arguments:
yt-transcript-cliThis opens a REPL where you can paste URLs one at a time, then press Enter on an empty line to process them all.
| Command | Description |
|---|---|
/help, /h |
Show help |
/status, /s |
Show pending URLs |
/clear, /c |
Clear pending URLs |
/process, /p |
Process pending URLs |
/quit, /q |
Exit |
| Flag | Description | Default |
|---|---|---|
-o, --output-dir |
Output directory for transcript files | . (current directory) |
-l, --lang |
Language code (e.g., en, es) |
auto-detect |
-q, --quiet |
Suppress progress messages | off |
-d, --delay |
Seconds between requests (rate limiting) | 1.5 |
-f, --file |
Read URLs from a file | - |
-i, --interactive |
Force interactive REPL mode | - |
https://www.youtube.com/watch?v=VIDEO_IDhttps://youtu.be/VIDEO_IDhttps://youtube.com/shorts/VIDEO_IDhttps://youtube.com/embed/VIDEO_IDhttps://www.youtube.com/playlist?list=PLAYLIST_ID- Plain video ID (11 characters)
- Transcripts are saved as
transcript_{VIDEO_ID}.txtin the output directory - Existing transcripts are skipped automatically (won't re-download)
- Playlists are expanded to individual videos
- A rate limit delay is applied between requests (configurable with
-d) - Output is a single continuous block of text (no line breaks between segments)
from yt_transcript import fetch_transcript, to_text, parse_youtube_url
video_id = parse_youtube_url("https://www.youtube.com/watch?v=VIDEO_ID")
segments = fetch_transcript(video_id)
text = to_text(segments)| Function | Description |
|---|---|
parse_youtube_url(url) |
Extract video ID from a YouTube URL |
fetch_transcript(video_id, lang=None) |
Fetch transcript segments |
to_text(segments) |
Convert segments to plain text |
is_playlist_url(url) |
Check if a URL contains a playlist |
fetch_playlist_video_ids(url) |
Get all video IDs from a playlist |