YouTube Embed Code Generator
Embed code for a YouTube video that starts and ends where you say.
The video and its part
YouTube takes whole seconds: a start rounds down and an end rounds up.
Options
What the frame is called to someone who cannot see it. The video’s own title is a good choice.
This writes YouTube’s own embed code. The video plays in YouTube’s player on your page, and nothing here changes the video or copies it.
How it works
1
Paste the link
A video or a Short. A time already in the link fills the start.
2
Set the part and the options
Type a start and an end, then choose autoplay, captions, privacy mode or a size.
3
Copy the code
Paste it into your page's HTML or an embed block, and preview it here first.
Every option is one YouTube documents on its player parameters page and its help page on embedding, apart from mute, which the player takes and autoplay needs.
What each part of the code does
| In the code | What it does |
|---|---|
| start=90 | Starts at 90 seconds, counted from the beginning. |
| end=150 | Stops at 150 seconds, also counted from the beginning, not from the start. |
| autoplay=1&mute=1 | Starts playing by itself, muted. |
| loop=1&playlist=VIDEO_ID | Plays the video again when it ends. |
| controls=0 | Hides the play bar. |
| cc_load_policy=1 | Shows captions from the start. |
| rel=0 | Suggests videos from the same channel at the end. |
| youtube-nocookie.com | Privacy-enhanced mode. |
| referrerpolicy="strict-origin-when-cross-origin" | Sends YouTube the referrer it requires, which avoids Error 153. |
To repeat only a part, slowed down or mirrored, use the YouTube looper: it plays in YouTube’s player too, and gives its own embed code.
Questions
How do I embed a YouTube video with a start and end time?
Add start and end to the embed address, each in whole seconds from the beginning of the video: /embed/VIDEO_ID?start=90&end=150 plays from 1:30 to 2:30. This page writes that for you from times like 1:30, and adds the rest of the code YouTube's own Share button gives.
Why does my embed start a second or two early?
YouTube's player starts at the keyframe nearest your start time, which its documentation says can be up to about two seconds earlier. The end is where you set it.
Why does the embed show Error 153?
YouTube requires embedders to send an HTTP Referer, and a page that sends none gets Error 153 instead of the video. The code here carries referrerpolicy="strict-origin-when-cross-origin", as YouTube's own does. If the error stays, look for a no-referrer setting on your site, in a meta tag or a security header.
Can I embed a YouTube Short?
Yes. Paste the Shorts link and the code uses the video's id with a tall 9:16 frame, which you can switch back to wide.
Why doesn't autoplay work?
Browsers only start a video by itself when it is muted, so the autoplay option here mutes it too. YouTube also notes that autoplayed embeds do not add to the video's views.
Can the embed loop just the part between start and end?
YouTube documents its loop for the whole video and calls its support for one video limited, so it may not repeat your part. Playback's looper repeats exactly a start to an end, and its page gives its own embed code.
What does privacy-enhanced mode do?
It loads the player from youtube-nocookie.com. YouTube's help says views of the embed then do not shape the viewer's browsing experience, and any ads are not personalised.
How big should the player be?
YouTube asks for a player at least 200 by 200 pixels and recommends at least 480 by 270 for a wide video. Fits the page makes it the full width of the space it is in, at the video's shape.
Why won't some videos play when embedded?
The owner can turn embedding off in YouTube Studio, and YouTube says age-restricted videos cannot be watched on most other sites. Neither can be changed from the embed code.
Related
- Want just that part to repeat? The looper's embed repeats your start to end, slowed down if you like.
- Sending it rather than putting it on a page? Make a link with the same start and end.
- Times in timecode or frames? Convert them to seconds for the start and end boxes.
