How to Find a YouTube Channel ID From Any URL (@handle, /c/, /user/)
You've got a spreadsheet of YouTube channels. Some rows say @MrBeast. Some say youtube.com/c/LinusTechTips. One person pasted a /user/ link from 2014. And whatever you're feeding them into wants the channel ID, the 24-character string that starts with UC.
The channel ID is the only identifier YouTube never changes. Handles get renamed, custom URLs get dropped, but UCXuqSBlHAE6Xw-yeJA0Tunw is Linus Tech Tips today and will be in ten years. That's why every serious pipeline keys on it.
Here are the three ways to get it, from one-off to automated, plus the trap that makes the "just view the page source" method quietly give you the wrong answer.
What a channel ID looks like
Always UC followed by 22 characters of letters, digits, hyphens and underscores. 24 characters total. If you've got something shorter, or something with an @ in it, that's a handle, not an ID.
The URL formats you'll run into
| Format | Example | Still works? |
|---|---|---|
| Handle | youtube.com/@MrBeast | Yes, current format |
| Channel ID | youtube.com/channel/UCX6OQ3DkcsbYNE6H8uQQuVA | Yes, permanent |
| Legacy username | youtube.com/user/LinusTechTips | Mostly |
| Legacy custom URL | youtube.com/c/LinusTechTips | Sometimes |
Those legacy formats are where people get stuck. We checked a few directly on YouTube. /c/LinusTechTips and /user/LinusTechTips still load the channel. /c/MrBeast6000 returns a plain 404 from YouTube itself, even though the channel is obviously alive. Old custom URLs don't always survive channel changes, and when YouTube drops one, no tool can resolve it. If a legacy link is dead, find the channel's current @handle and start from that.
Method 1: By hand, in the browser
For a single channel, the quickest way is the page source:
- Open the channel page in your browser.
- View the page source (Ctrl+U, or Cmd+Option+U on a Mac).
- Search for
rel="canonical".
You'll find a line like this:
<link
rel="canonical"
href="https://www.youtube.com/channel/UCXuqSBlHAE6Xw-yeJA0Tunw"
/>
That's the ID. It works the same whether you opened the @handle page or a legacy /c/ link. The canonical tag always points at the permanent /channel/ URL.
The trap: don't search for "channelId"
The tutorial advice you'll find everywhere says to search the source for channelId. Don't. A channel page mentions a lot of channels: recommended ones, featured ones, collaborators. We checked three channel pages and found between 6 and 12 different "channelId" values in each. On all three, the first match was a different channel.
If you're scripting this, a regex for the first "channelId" will give you a confidently wrong ID. Use the canonical link, or one of these, which all agreed with it in our checks:
<meta property="og:url" content="https://www.youtube.com/channel/UC..."><meta itemprop="identifier" content="UC...">"externalId":"UC..."
Method 2: By API, for a whole list
Page-scraping is fine for five channels. For five hundred, you want something that takes whatever format you have and hands back the ID. The /youtube/channel endpoint accepts a handle, a url or a channelId, and every response includes channelId:
const API = "https://api.sociavault.com/v1/scrape";
const KEY = process.env.SOCIAVAULT_API_KEY;
async function channelIdFor(input) {
const raw = String(input).trim();
const params = new URLSearchParams(
/^https?:\/\//i.test(raw) ? { url: raw } : { handle: raw },
);
const res = await fetch(`${API}/youtube/channel?${params}`, {
headers: { "x-api-key": KEY },
});
const body = await res.json();
if (body?.error) return { input, error: body.error };
const d = body?.data ?? {};
return {
input,
channelId: d.channelId ?? null,
handle: d.handle ?? null,
name: d.name ?? null,
};
}
const inputs = [
"@MrBeast",
"https://www.youtube.com/c/LinusTechTips",
"https://www.youtube.com/user/LinusTechTips",
];
for (const i of inputs) {
console.log(await channelIdFor(i));
await new Promise((r) => setTimeout(r, 500)); // be polite in loops
}
And in Python:
import os, re, time, requests
API = "https://api.sociavault.com/v1/scrape"
HEADERS = {"x-api-key": os.environ["SOCIAVAULT_API_KEY"]}
def channel_id_for(raw):
raw = str(raw).strip()
params = {"url": raw} if re.match(r"^https?://", raw, re.I) else {"handle": raw}
body = requests.get(f"{API}/youtube/channel", params=params, headers=HEADERS, timeout=60).json()
if body.get("error"):
return {"input": raw, "error": body["error"]}
d = body.get("data") or {}
return {"input": raw, "channelId": d.get("channelId"), "handle": d.get("handle"), "name": d.get("name")}
for i in ["@MrBeast", "https://www.youtube.com/c/LinusTechTips"]:
print(channel_id_for(i))
time.sleep(0.5)
When we ran the /c/LinusTechTips and /user/LinusTechTips links through it, both came back as UCXuqSBlHAE6Xw-yeJA0Tunw, with the current handle (@LinusTechTips) alongside. That second field is handy: it's the modern URL to write back into your spreadsheet.
Handles work with or without the @. If all you have is a channel's name rather than a link, YouTube search will find the channel first. You also get the rest of the channel record in the same call, including subscriberCount, videoCount and viewCount. If those are what you're really after, our post on getting an exact subscriber count goes deeper on what's rounded and what isn't.
Method 3: YouTube's own Data API
If you already have a Google Cloud project, the official YouTube Data API v3 can resolve handles too, via the channels endpoint with forHandle. It's free within its daily quota and it's the authoritative source.
Two things make it awkward for messy lists. It wants a clean handle or ID, so legacy /c/ URLs need their own handling first. And you need an API key, a project and quota management before your first request. For a few hundred known handles it's a good option. For a pile of mixed-format links from different people, normalising them yourself is most of the work.
A bonus: the uploads playlist trick
Once you have the ID, there's a neat shortcut. Every channel has an automatic playlist of all its uploads, and its ID is the channel ID with the UC swapped for UU:
Channel: UCXuqSBlHAE6Xw-yeJA0Tunw
Uploads: UUXuqSBlHAE6Xw-yeJA0Tunw
We checked youtube.com/playlist?list=UUXuqSBlHAE6Xw-yeJA0Tunw and it loads as "Uploads from Linus Tech Tips." Useful when a tool wants a playlist rather than a channel.
The honest limits
- Dead legacy URLs stay dead. If YouTube returns a 404 for an old
/c/link, nothing can map it to an ID. You need the current handle. - Page-source scraping is fragile. YouTube changes its markup, and in some regions you'll hit a cookie consent page before the channel loads. Fine for a one-off, risky in production.
- Handles can be reassigned. A handle points at whoever holds it today. That's exactly why you store the ID, not the handle.
- A channel ID tells you nothing about a video. Video IDs are a separate 11-character format. Don't mix them up in the same column.
Frequently Asked Questions
What is a YouTube channel ID?
It's the permanent identifier for a channel: UC followed by 22 characters. It never changes, even when the channel changes its name, handle or custom URL.
How do I find a channel ID from an @handle?
Open the channel, view the page source and find the rel="canonical" link, which points at youtube.com/channel/UC.... For many channels at once, use an API that accepts the handle and returns the channelId.
Do old /c/ and /user/ URLs still work?
Many do. In our checks, /user/LinusTechTips and /c/LinusTechTips both still loaded, but /c/MrBeast6000 returned a 404 on YouTube itself. If a legacy link is dead, look up the channel's current handle instead.
Why did I get the wrong channel ID from the page source?
You probably matched the first "channelId" in the HTML. Channel pages reference many other channels, and in our checks the first match was a different channel every time. Use the canonical link, og:url, or externalId.
Can I get the channel ID without an API key?
Yes, from the page source by hand. To do it for a list of channels reliably, you'll want an API, either YouTube's own Data API or a scraping API that accepts mixed URL formats.
What's the difference between a channel ID and a handle?
The handle (like @MrBeast) is a readable name the owner can change. The channel ID is the fixed internal identifier. Store the ID as your key and keep the handle for display.
Got a column of mixed YouTube links to clean up? Sign up for 50 free credits and run them through the script above. Each lookup returns the ID and the current handle in one call.
Found this helpful?
Share it with others who might benefit
Ready to Try SociaVault?
Start extracting social media data with our powerful API. No credit card required.