Every YouTube video has a unique ID -- it's that random-looking string of characters you see in the URL. You might never think about it, but if you're trying to embed a video, build a tool, or just grab a thumbnail, you'll need to know how to find it.
So What Exactly Is It?
A YouTube video ID is 11 characters long. It can include letters (both uppercase and lowercase), numbers, hyphens, and underscores. That's it.
For example, in the URL https://www.youtube.com/watch?v=dQw4w9WgXcQ, the video ID is dQw4w9WgXcQ. This same string pops up everywhere YouTube references that video -- in embed codes, API responses, thumbnail URLs, you name it.
Fun fact: with 64 possible characters in each of the 11 positions, there are over 73 quintillion possible video IDs. YouTube won't be running out anytime soon.
Finding the Video ID in Different URL Formats
YouTube uses a bunch of different URL styles, and the video ID sits in a different spot for each one. Here's where to look.
Regular Watch URL
This is the one you see in your browser most of the time:
https://www.youtube.com/watch?v=dQw4w9WgXcQ
The ID is right after v=. If there's other stuff after it like &t=120, just ignore everything from the & onward.
Short URL (youtu.be)
YouTube's shortened links look like this:
https://youtu.be/dQw4w9WgXcQ
Everything after the last slash is the video ID. You'll see these a lot in tweets and text messages.
Embed URL
When you embed a video on a website, the URL looks like:
https://www.youtube.com/embed/dQw4w9WgXcQ
The ID comes right after /embed/.
Shorts URL
Shorts have their own format:
https://www.youtube.com/shorts/dQw4w9WgXcQ
Same idea -- the ID is after /shorts/. Shorts use the exact same 11-character ID system as regular videos.
YouTube Music URL
YouTube Music just uses a different subdomain:
https://music.youtube.com/watch?v=dQw4w9WgXcQ
Same as the regular watch URL -- grab the value after v=.
Mobile App Links
Links shared from the app usually use the youtu.be format or the standard watch URL. You might see extra tracking stuff like &si= tacked on -- just ignore those parts.
Quick Way to Extract It by Hand
Here's a simple cheat sheet:
- URL has
?v=in it? Take the 11 characters afterv=(stop at any&). - URL has
/embed/? Take the 11 characters after it. - URL has
/shorts/? Take the 11 characters after it. - URL starts with
youtu.be/? Take the 11 characters after the slash.
If you're dealing with a bunch of URLs at once, a tool will be way faster and less error-prone than doing it by hand.
Why You'd Actually Need a Video ID
If you're a developer or a creator who gets into the technical side of things, video IDs come up all the time.
Working with the YouTube API
The YouTube Data API uses video IDs for basically everything. Want to pull a video's stats, comments, or metadata? You need the ID. Here's what a typical API call looks like:
GET https://www.googleapis.com/youtube/v3/videos?id=dQw4w9WgXcQ&part=snippet,statistics&key=YOUR_API_KEY
If you're building any kind of dashboard or tool that works with YouTube data, you'll be passing video IDs around constantly.
Getting Thumbnails Directly
You don't need the API to grab a video's thumbnail. Just plug the ID into one of these URLs:
- Max resolution:
https://img.youtube.com/vi/VIDEO_ID/maxresdefault.jpg - Standard:
https://img.youtube.com/vi/VIDEO_ID/sddefault.jpg - High quality:
https://img.youtube.com/vi/VIDEO_ID/hqdefault.jpg - Default:
https://img.youtube.com/vi/VIDEO_ID/default.jpg
This is really handy when you need thumbnails without dealing with API rate limits or authentication.
Building Embed Codes
If you're generating embed codes programmatically, the video ID is the piece you plug into the iframe's src URL along with whatever player parameters you want.
Deep Linking and Automation
Video IDs are what you use to link directly to specific videos in apps, build playlists on the fly, create video comparison tools, or automate content workflows.
How to Check if a Video ID is Valid
The rules are simple:
- Exactly 11 characters long
- Only contains: A-Z, a-z, 0-9, hyphens (-), and underscores (_)
- A valid format doesn't mean the video actually exists -- it just means the format is correct
If you want a regex for it:
/^[A-Za-z0-9_-]{11}$/
To actually confirm a video exists, you'd need to hit the API or try loading the video's page.
Common Mistakes to Avoid
- Mixing up channel IDs and video IDs: Channel IDs start with "UC" and are 24 characters long. Totally different thing.
- Including extra URL parameters: Make sure you strip off anything after the ID, like
&t=120or&list=. - Treating IDs as case-insensitive: They're not.
dQw4w9WgXcQanddqw4w9wgxcqare completely different IDs. - Getting the wrong number of characters: It's always exactly 11. If you've got more or fewer, something went wrong.
A Note on Privacy
Video IDs are public information -- they're right there in every URL that gets shared. But if you're building tools that process lots of video IDs, be mindful of YouTube's Terms of Service and API usage limits. Respect rate limits and don't scrape in ways that violate their policies.