If you’ve ever found yourself in a situation where you’re on the go, stuck without Wi-Fi, and just have to watch that YouTube video you love, you’re probably thinking about ways to download it. While there are plenty of apps and third-party tools to do this, I’ll show you how to download YouTube videos directly to your Mac using the command prompt. Yep, no extra software needed — just the power of the terminal!
Step 1: Install Homebrew (If You Don’t Have It)
Before we get started, let’s make sure we have Homebrew installed on your Mac. Homebrew is a package manager for macOS, which allows you to install software via the terminal. You’ll need it to install a tool called youtube-dl, which will handle the downloading part.
Here’s how you install Homebrew:
- Open Terminal (you can search for it in Spotlight or find it in Applications → Utilities).
- Paste the following command into the terminal and press Enter:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 2: Install youtube-dl
Once Homebrew is up and running, we can use it to install youtube-dl — a command-line tool that’s incredibly efficient at downloading videos from YouTube and many other websites.
To install it, just type this command into the terminal and hit Enter:
Homebrew will automatically download and install youtube-dl for you. You’re just a few steps away from downloading your favorite videos!
Step 3: Downloading Videos
- Now that youtube-dl is installed, downloading YouTube videos is as simple as typing a command.
- Find the YouTube Video You Want to Download: Go to YouTube and copy the URL of the video you want to download.
- For example:
https://www.youtube.com/watch?v=ABC123xyz
- Download the Video: Go back to the terminal and type the following command:
youtube-dl https://www.youtube.com/watch?v=ABC123xyz
Press Enter, and youtube-dl will automatically start downloading the video to your current directory (usually your home folder).
Step 4: Optional Settings — Change Video Quality and Format
- You can customize the video download with some additional options:
- To download the video in a specific quality, add the
-f
flag followed by the format code. For example: - (Here,
22
represents 720p video quality. You can see all available format options for a specific video by typingyoutube-dl -F <video-url>
.) - To download audio-only (MP3 format), use:
This will extract just the audio in MP3 format, which is perfect for music.
Once the video is downloaded, you can open it like any other file on your Mac! The default file format will be in MP4, but you can convert it into different formats if you prefer.
Troubleshooting Tips
- "Command not found" error: If you get a “command not found” error for youtube-dl, double-check that Homebrew and youtube-dl are correctly installed. You can try running
brew update
andbrew reinstall youtube-dl
. - Update youtube-dl: Sometimes, YouTube updates its system, and you’ll need to update youtube-dl to keep it working. Just run:
brew update
brew upgrade youtube-dl
- Video unavailable: If a video is unavailable in some regions or has been removed, youtube-dl won’t be able to download it. You can try downloading from a VPN, if needed.
Wrapping It Up
And there you have it! You can now easily download YouTube videos to your Mac using just the command prompt and youtube-dl. Whether you want to watch videos offline during your commute or save a tutorial for later, this method gives you complete control without the hassle of third-party apps or websites.
If you ever run into any issues, just remember that youtube-dl is constantly updated, and there’s a ton of support from the community. Happy downloading, and enjoy your offline YouTube videos!