Regex to extract a YouTube video ID in your own code
const YT_ID = /(?:youtube(?:-nocookie)?\.com\/(?:watch\?(?:.*&)?v=|embed\/|shorts\/|live\/|v\/)|youtu\.be\/)([A-Za-z0-9_-]{11})/;
function getVideoId(url) {
const m = url.match(YT_ID);
return m ? m[1] : null;
}
getVideoId("https://youtu.be/dQw4w9WgXcQ?si=abc"); // "dQw4w9WgXcQ"import re
YT_ID = re.compile(r"(?:youtube(?:-nocookie)?\.com/(?:watch\?(?:.*&)?v=|embed/|shorts/|live/|v/)|youtu\.be/)([A-Za-z0-9_-]{11})")
def get_video_id(url):
m = YT_ID.search(url)
return m.group(1) if m else None
get_video_id("https://youtu.be/dQw4w9WgXcQ?si=abc") # 'dQw4w9WgXcQ'How to use
Paste a YouTube link
Paste into the YouTube URL field on the One link tab. Watch, youtu.be, Shorts, live and embed links all work, with or without https://. Try a sample link fills in an example.
Read and copy the results
Results appear instantly: Video ID, Clean link, Short URL, Embed URL, start time, playlist ID and a table of every query parameter. Type a time such as 1:30 under Timestamp link to get links that start there.
Process many links at once
Switch to the Bulk tab and paste up to 500 links, one per line. Lines with no ID are flagged. Use Copy IDs, Copy CSV or Download CSV to move the results into a spreadsheet.
Why YouTube Video ID Finder
- Finds the video ID in watch, youtu.be, Shorts, live and embed links as you type.
- Shows every query parameter and a clean link with tracking like si= removed.
- Bulk mode handles up to 500 links and exports a CSV.
- Builds timestamp links and includes a regex snippet for JavaScript and Python.
Where the video ID sits in each YouTube URL
YouTube has several link formats, but every one that points to a single video carries the same 11-character ID. Only its position changes. The examples below all point to the same video, dQw4w9WgXcQ.
Anything after a ? or & that isn't v is extra information: a playlist, a start time or a tracking value. The ID itself never contains ? or &. Paste any of these into the tool to see the ID and each parameter split out.
| Link type | Example | Where the ID is |
|---|---|---|
| Watch | youtube.com/watch?v=dQw4w9WgXcQ | Value of v= |
| Mobile watch | m.youtube.com/watch?v=dQw4w9WgXcQ | Value of v= |
| Short link | youtu.be/dQw4w9WgXcQ?si=... | First part of the path |
| Shorts | youtube.com/shorts/dQw4w9WgXcQ | After /shorts/ |
| Live | youtube.com/live/dQw4w9WgXcQ | After /live/ |
| Embed | youtube.com/embed/dQw4w9WgXcQ?start=30 | After /embed/ |
| In a playlist | youtube.com/watch?v=dQw4w9WgXcQ&list=PL...&index=2 | Value of v=; list= is the playlist |
Extracting the ID in your own code
The regex in the tool matches the known path and parameter positions and captures exactly 11 characters. That is more reliable than splitting the string on = or /, which breaks on real-world links.
- Don't assume v is the first parameter. Mobile share links often start with feature= and put v= later.
- Strip the query string from youtu.be links, or si= will end up attached to the ID.
- IDs can contain hyphens and underscores, so a pattern of only letters and digits will miss some.
- Check the result is exactly 11 characters before storing it.
- A regex can't tell you whether a video is public. Use the YouTube Data API or an oEmbed request if you need that.
- Keep the original URL next to the ID if you need the timestamp or playlist later.