Sunday, February 21, 2016

Get YouTube video id form URL using Javascript.

In this topics I will discus about "How to get YouTube video id from its URL". For this create a simple javascript function as bellow -
function YouTubeGetID(url){
var ID = '';
url = url.replace(/(>|<)/gi,'').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/);
if(url[2] !== undefined) {
ID = url[2].split(/[^0-9a-z_\-]/i);
ID = ID[0];
else {
ID = url;
return ID;
Call the function as bellow -
var youtubeurl="";
And then you will get something output for example url as bellow -
I hope it will helpful for you.
Now it's time for enjoy.

For any comment or suggestion on this topics, please mention your comment on comment box bellow.  


  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here.
    Kindly keep blogging. If anyone wants to become a Front end developer learn from javascript and jquery training in chennai .
    or learn thru Javascript Training in Chennai.
    Nowadays JavaScript has tons of job opportunities on various vertical industry. javascript and jquery training in chennai


  2. Thanks, Learned a lot of new things from your post! Good creation and HATS OFF to the creativity of your mind.
    Very interesting and useful blog!
    javascript Training in Gurgaon



Copyright @ 2014 Tech Tutorial .