yt-dlp guide: install, JavaScript runtime, formats, audio, subtitles and safe use
yt-dlp began in 2020 as a fork of youtube-dl, which had slowed down, and it is now the version most people mean when they talk about downloading video from the command line. It supports more than a thousand sites, fixes breakages quickly, and adds features youtube-dl never had, such as SponsorBlock integration, better format sorting and browser cookie import. Many graphical download apps and media servers use it underneath.
The last year brought two changes that break old setups. In October 2025, version 2025.10.22 dropped Python 3.9. In November 2025, version 2025.11.12 made an external JavaScript runtime necessary for full YouTube support. If yt-dlp suddenly shows far fewer formats or fails on YouTube, a missing runtime is the most likely cause.
Installing yt-dlp
| Method | Command | Notes |
|---|---|---|
| pip | pip install -U "yt-dlp[default]" | Includes yt-dlp-ejs |
| pipx | pipx install "yt-dlp[default]" | Keeps it isolated |
| Homebrew | brew install yt-dlp | |
| Windows | winget install yt-dlp.yt-dlp | |
| Standalone binary | Download from GitHub releases | Bundles Python and yt-dlp-ejs |
Also install:
- ffmpeg, for merging separate video and audio streams and converting formats.
brew install ffmpeg,winget install ffmpegor your Linux package manager. - A JavaScript runtime for YouTube. Deno is the default:
brew install denoorcurl -fsSL https://deno.land/install.sh | sh. Node 22 or later also works.
The JavaScript runtime requirement
YouTube now protects its video URLs with JavaScript challenges. yt-dlp handles them with yt-dlp-ejs, a set of scripts it runs in an external runtime. The supported runtimes since release 2026.06.09:
| Runtime | Minimum version | Status |
|---|---|---|
| Deno | 2.3 | Default and recommended |
| Node | 22 | Supported, use --js-runtimes node |
| QuickJS | 2023-12-9 (2025-4-26 or later for speed) | Use --js-runtimes quickjs |
| QuickJS-ng | Any (0.12.0 or later for speed) | Use --js-runtimes quickjs |
| Bun | 1.2.11 to 1.3.14 only | Deprecated, use --js-runtimes bun |
Only Deno is turned on by default. Add the --js-runtimes line for any other runtime to your config file so you do not need to pass it every time. Deno also runs the scripts with restricted permissions, with no file system or network access, which Bun does not offer.
Since 2026.01.29, yt-dlp can also use Deno installed as a Python package, which helps where you cannot install system software. If you installed yt-dlp with pip without the [default] extra, add the scripts with pip install -U yt-dlp-ejs.
Basic downloads
yt-dlp "https://www.youtube.com/watch?v=VIDEO_ID"
Put URLs in quotes so your shell does not treat & or ? as special. By default yt-dlp picks the best video and audio and merges them into one file named after the video title.
| Task | Command |
|---|---|
| List formats | yt-dlp -F URL |
| Best up to 1080p | yt-dlp -f "bv*[height<=1080]+ba/b" URL |
| Prefer MP4 at 720p | yt-dlp -S res:720,ext:mp4 URL |
| Audio only, MP3 | yt-dlp -x --audio-format mp3 URL |
| Original audio | yt-dlp -f bestaudio URL |
| Name files | yt-dlp -o "%(upload_date)s %(title)s.%(ext)s" URL |
Playlists and channels
A playlist or channel URL downloads every video. Useful options:
-I 1:10downloads only items 1 to 10.--download-archive done.txtrecords finished videos and skips them next time, which makes channel updates incremental.-o "%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s"keeps files in order inside a folder.--dateafter 20260101limits by upload date.
Subtitles, metadata and SponsorBlock
| Option | Effect |
|---|---|
--write-subs --sub-langs en | Download English subtitles |
--write-auto-subs | Include auto-generated subtitles |
--embed-subs | Put subtitles inside the video file |
--embed-metadata | Add title, artist and date tags |
--embed-thumbnail | Add cover art |
--sponsorblock-remove sponsor | Cut sponsor segments using SponsorBlock data |
--embed-chapters | Keep chapter markers |
Subtitle files are handy for AI work: yt-dlp --skip-download --write-auto-subs --sub-langs en URL saves only the transcript, which you can summarize or search without downloading the video.
Config files
Options you always use can go in a config file, one option per line:
# ~/.config/yt-dlp/config
-o ~/Videos/%(title)s.%(ext)s
--embed-metadata
--embed-subs
--sub-langs en
yt-dlp also reads a yt-dlp.conf in the current folder. Use --ignore-config to skip config for one run.
Cookies and sign-in
Some videos need you to be signed in, such as age-restricted or members-only content. --cookies-from-browser firefox reads cookies from your browser, and --cookies cookies.txt uses an exported cookie file. Only use your own account. Cookie files hold your session, so keep them private and do not paste them into chats with AI assistants or bug reports.
Security changes in 2026
Release 2026.06.09 fixed three security issues:
- CVE-2026-50019. Cookies could leak to the wrong site when downloading through curl.
- CVE-2026-50023. Downloads with dangerous file extensions are now blocked.
- CVE-2026-50574. Code execution through crafted manifests when using aria2c. yt-dlp removed HLS and DASH support through aria2c. Use the built-in downloader with
-N 4for parallel fragments instead.
The same release restricted --exec to safe conversions. Use the %(...)q form, which quotes values for the shell, when passing fields such as the title to a command. If you have scripts that use --exec or --downloader aria2c, test them after updating. --compat-options 2025, added in 2026.01.29, restores some older behaviors during migration.
Updating
Sites change often, and an out-of-date yt-dlp is the usual reason downloads fail.
| Install | Update |
|---|---|
| Standalone binary | yt-dlp -U |
| pip | pip install -U "yt-dlp[default]" |
| Homebrew | brew upgrade yt-dlp |
| Nightly channel | yt-dlp --update-to nightly |
Update yt-dlp-ejs and your JavaScript runtime at the same time.
Legal and ethical limits
yt-dlp is a general tool, and its legality depends on what you download. Downloading your own content, Creative Commons or public-domain videos, or material for uses your local law allows is generally fine. Downloading copyrighted videos without permission can infringe copyright, and most video sites forbid downloading in their terms of service. Do not use yt-dlp to bypass paywalls or redistribute others' work. When collecting video for AI training or research datasets, check licenses and get legal advice for anything beyond personal use.
Limits
Breaks when sites change. Expect to update often, and use nightly builds when the stable release is behind.
Rate limiting. Large playlists can trigger throttling or temporary blocks. --sleep-interval 5 and --limit-rate reduce this.
More dependencies than before. Python, ffmpeg and a JavaScript runtime all need to stay current for YouTube.
yt-dlp compared with other tools
| Tool | Type | Sites | Notes |
|---|---|---|---|
| yt-dlp | Command line | 1,000+ | Most active, most options |
| youtube-dl | Command line | Many | Original project, far fewer updates |
| gallery-dl | Command line | Image and gallery sites | Complements yt-dlp |
| Desktop front ends | GUI | Varies | Many wrap yt-dlp |
Choose yt-dlp for downloading or archiving media you have the right to keep, and for pulling transcripts into AI tools. See the terminal tools guide for more command-line tools.
Frequently asked questions
Why does yt-dlp say it needs a JavaScript runtime?
YouTube's player now relies on JavaScript challenges that yt-dlp's built-in Python interpreter could no longer solve reliably. Since release 2025.11.12, yt-dlp runs that code in an external runtime through its yt-dlp-ejs component. Install Deno 2.3 or later, which yt-dlp uses by default, or Node 22 or later. Without one, many YouTube formats are missing or downloads fail. Installing with pip install -U "yt-dlp[default]" also pulls in yt-dlp-ejs.
How do I download only the audio?
Run yt-dlp -x --audio-format mp3 followed by the URL. -x extracts audio, and --audio-format converts it, which needs ffmpeg. To keep the original audio without converting, which is better quality, leave out --audio-format or use -f bestaudio. Add --embed-thumbnail and --embed-metadata to include cover art and tags.
How do I choose video quality?
yt-dlp downloads the best video and audio and merges them by default. Use -F to list formats, then -f with a format code, or a selector such as -f "bv*[height<=1080]+ba/b" for the best video up to 1080p plus the best audio. -S sorts formats, for example -S res:720,ext:mp4 to prefer 720p MP4. Merging separate streams needs ffmpeg.
How do I update yt-dlp?
Sites change often, so update regularly. Run yt-dlp -U for the standalone binary, pip install -U "yt-dlp[default]" for a pip install, or brew upgrade yt-dlp for Homebrew. If YouTube downloads break, update yt-dlp, yt-dlp-ejs and your JavaScript runtime before reporting a bug. The nightly channel, yt-dlp --update-to nightly, often has fixes first.
Is it legal to use yt-dlp?
The tool itself is legal in most countries and has many lawful uses, such as downloading your own uploads, Creative Commons videos, public-domain material and content for research or accessibility where the law allows. Downloading copyrighted material without permission can breach copyright law and usually breaches the site's terms of service. Check the law where you live and the terms of the site before downloading.