I'm writing code to validate YouTube URLs. Is it guaranteed that the video ID, such as oHg5SJYRHA0, is always exactly 11 characters long, or can it sometimes be shorter or longer? Is there any official documentation about this?

  • At least until 5.20e+19 videos are made ;)
    – Jason McCreary
    Commented Mar 26, 2011 at 2:17
  • @Jason damn you! what calculator are you using!
    – Saad
    Commented Mar 26, 2011 at 2:23
  • 2
    The max. combination in 11 chars seems like a large number, but it wont't be probably enaugh in a few years since the number of uploaded youtube videos grows exponentialy... So do NOT count on that if you are creating not-for-one-year websites.
    – jave.web
    Commented Aug 12, 2014 at 16:52
  • @jave.web You're late to the party. I was asking for authoritative sources, not for someone to argue whether 64^11 is a big number. There could be other reasons that some video codes could be different format than running out of them. For example, there might be legacy videos with shorter codes, or videos that are stored in a separate system, with a different code format entirely. The accepted answer contains the most authoritative answer I've seen so far.
    – nitro2k01
    Commented Aug 15, 2014 at 21:51
  • my comment still applies, especially in 2014, and just supports the accepted answer ;)
    – jave.web
    Commented Aug 18, 2014 at 21:55

3 Answers 3


They'll probably stick to 11 chars for a long time. Each character has 64 possible values:

2*26 letters (lowercase and uppercase) + 10 for the digits, + 2 for "_" and "-" chars

2 * 26 + 10 + 2 = 64

Then 11 characters in total:

64^11 = 73786976294838210000 (or more or less "73,7e18")

Of course not all combination will be used, depending on their algorithm, but they are probably not going to change it anytime soon. Words from a YouTube developer state that they do not guarantee, though:

I don't see anywhere in the documentation where we officially commit to a standard length of 11 characters for YouTube video ids. It's one of those things where we have a current implementation, and it may stay that way indefinitely. But we're not offering any official commitment to that, so proceed at your own risk.

A better approach, though one that's more involved, would be to take each video id and make a request to the YouTube API to see if it's valid. E.g., make an HTTP GET to


and see if you get back a HTTP 200 response. Of course, if you take that approach, videos that have been removed from YouTube will come back as invalid (which may or may not be what you want) and videos that have been very recently uploaded to YouTube might also come back as invalid.

Cheers, -Jeff Posnick, YouTube API Team

Source: https://web.archive.org/web/20120306111051/http://osdir.com/ml/youtube-api-gdata/2009-10/msg00237.html

  • 1
    @Diego: If you're going to cite so many digits, you may as well show the last few: 64^11 = 2^66 = 73,786,976,294,838,206,464 With 0.5 rounding, the engineering form is 73.787e18 .
    – user60228
    Commented Feb 9, 2014 at 21:46
  • I agree with @user60228, do not show full digits unless you show full accuracy or detail otherwise. Just interesting to some of us to know the full mathematical truth. (P.S. Great answer!)
    – Xonatron
    Commented Feb 25, 2015 at 21:01

Something worth pointing out, a couple of the URLs point to the same video. For example, in the videos posted below, they are all "The 2015 Nobel Prizes!" by Scishow:

Also, if you change the last character to C or D that will work too.

  • 2
    You may have found a flaw. Apparently every video has at least 4 urls. In the case you mention A, B, C, and D all point to A. Also, E, F, G, and H point to E; I, J, K, and L point to I. And so on. And that's true for every video I tested. Commented Aug 24, 2017 at 15:33
  • This appears to no longer be the case as of posting this comment.
    – nitro2k01
    Commented Nov 12, 2018 at 6:24

Yes, they always have 11 characters.

  • 3
    Do you have any information to back that up?
    – ale
    Commented Jun 15, 2012 at 13:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.