Get the YouTube, Vimeo, Vine, Microsoft Steam, Dailymotion, TikTok or VideoPress video id from a url or embed string.

Usage no npm install needed!

<script type="module">
  import getVideoId from '';


get-video-id codecov

Get the YouTube, Vimeo, Vine, VideoPress, TikTok, Microsoft Stream and Dailymotion video id from a url or embed string.

Pull Requests are welcome if you would like to see support for other video services or if you find an unsupported video url pattern.


$ npm install --save get-video-id


You can use this module in Node.js or in the browser. See below for the different importing options.


const getVideoId = require('get-video-id');

ES2015 Module

import getVideoId from 'get-video-id';


<script src=""></script>


Simply supply the module with a url or embed string matching any of the patterns known by this module and its metadata of id and service will be returned:

import getVideoId from 'get-video-id';

//=> { id: '8rSH8-pbHZ0', service: 'youtube' }

const { id } = getVideoId('');
//=> '8rSH8-pbHZ0'

get-video-id can also find the video buried in a Google redirection URL if it contains a reference to any of the supported URL patterns.

//=> { id: 'eG1uDU0rSLw', service: 'youtube' }



Returns a metadata Object with the video id and service name:

  id: 'String',
  service: 'String'


Type: String

The url (or embed code) from which you want to find the video id. See the Patterns section to see the formats that can be supplied.


This module works on the url / embed patterns below. (where * is the id and ? or & are parameter strings):


YouTube Shortcodes*?***

YouTube Shorts***

YouTube /v/ or /vi/**?*?

YouTube v= or vi=**?&**&*&*

YouTube /e/**?**?

YouTube image links /vi/*/ or /an_webp/*/*/hqdefault.jpg

YouTube embed*?*

YouTube user**?*

YouTube iframe

<iframe width="560" height="315" src="*" frameborder="0" allowfullscreen></iframe>

YouTube -nocookie*?

YouTube Attribution Link*%26*&**

Google Redirection to YouTube<YOUTUBE_URL><YOUTUBE_URL>


Vimeo urls**?**?**?

Vimeo swf embed

Vimeo events*

Vimeo iframe

<iframe src="*" ...

Vimeo unlisted/private urls*/privateHash

⚠️ Please note: That get-video-id will extract the id from the private/unlisted URLs formats for Vimeo, but the private hash would still be required to rebuild the URL in order to make it reachable/sharable in a browser. If you use get-video-id to help you rebuild URLs, you will want to look for this pattern yourself and remember to include the privateHash in the url you want to share. get-video-id focuses on extracing video ids, and ignores any other special paramaters or formats at the moment.


Vine urls*

Vine iframe

<iframe src="*/embed/simple" width="600" height="600" frameborder="0"></iframe>
<iframe src="*/embed/postcard" width="600" height="600" frameborder="0"></iframe>


VideoPress urls**

VideoPress iframes

<iframe src="" width="600" height="600"></iframe>

Microsoft Stream

Microsoft Stream urls**

Microsoft Stream iframes

<iframe src="*?&" width="640" height="360"></iframe>


TikTok urls*/video/**/video/*?

:warning: Unsupported TikTok urls

  • Shortlink URL (requires a fetch/redirect to find the real id) :


Dailymotion urls*_text***?playlist=*

Dailymotion iframes

<iframe src="*" width="600" height="600"></iframe>

:warning: Unsupported Dailymotion urls

  • Channel id urls:*_title


If you discover a url pattern that is not covered by this module, please open an issue to report it, or submit a Pull Request. For any submitted pull requests, please ensure that you include unit test(s) to fully cover your code contribution(s).


MIT © Michael Wuergler