YouTube Embed Code Generator
Build the embed code for any YouTube video or Short, with a start time, autoplay, loop and privacy-enhanced mode, and see a live preview.
How it works
How to embed a YouTube video
Responsive by default, so the player fits every screen.
-
Copy the video link
Copy the link of the YouTube video or Short you want to put on your page.
-
Choose options
Paste it above and set a start time, autoplay, loop or any other option. The code updates as you go.
-
Copy the code
Copy the embed code and paste it into your page's HTML, or a "Custom HTML" block in WordPress, Wix or Webflow.
Good to know
YouTube embed options, explained
What each option does
- Start at / End at: plays only part of the video. Enter times like
90,1:30or1m30s. - Responsive size: the player fills the width of its container and keeps a 16:9 shape (9:16 for Shorts), so it fits phones and desktops. Turn it off for a fixed 560 × 315 player.
- Privacy-enhanced mode: uses
youtube-nocookie.com. YouTube says it doesn't store information about visitors on your page unless they play the video. - Show player controls: turn off to hide the progress bar and buttons, for a cleaner background video.
- Autoplay: browsers only autoplay video without sound, so autoplay always adds mute.
- Loop: replays the video when it ends. YouTube needs the video ID repeated as a playlist for this, which the code does for you.
- Captions on: shows captions by default, when the video has them.
Embedding a YouTube Short
Paste a Shorts link and the code switches to a vertical 9:16 player, so the Short isn't letterboxed inside a wide frame.
Where to paste the code
- WordPress: add a Custom HTML block.
- Wix, Squarespace, Webflow: use the Embed or Code element.
- Your own site: paste it into the HTML where the video should appear.
When a video won't embed
Creators can turn embedding off. Those videos show "Video unavailable" in the player, and only the creator can change that.
Tools
More free tools
-
YouTube Timestamp Link Generator
Make a link that opens a video at an exact minute and second.
Open tool -
Shorts Downloader
Save vertical YouTube Shorts in full HD with sound.
Open tool -
YouTube Video Downloader
Save YouTube videos as MP4 with sound, in every quality up to 4K.
Open tool -
YouTube Audio Downloader
Keep just the sound of a video as an M4A (AAC) file.
Open tool -
YouTube Thumbnail Downloader
Save the thumbnail of any video or Short in every size YouTube has, up to 1280×720.
Open tool -
YouTube Profile Picture Downloader
Download a channel's profile picture at its original upload size.
Open tool
Learn more
Guides and help
-
How to download YouTube videos and Shorts
Step-by-step for desktop, Android and iPhone, supported links and fixes for common errors.
Read guide -
YouTube video quality and formats explained
Resolutions, frame rates, H.264 vs VP9 vs AV1, and which download to pick.
Read guide -
Is it legal to download YouTube videos?
What YouTube's terms and copyright law allow, and the cases where downloading is fine.
Read guide
FAQ
Embed code questions
How do I embed a YouTube video?
Paste the video's link above, choose your options and copy the code. Paste it into your page's HTML or a "Custom HTML" block in your site builder.
How do I make a YouTube embed start at a specific time?
Enter the time in Start at, for example 1:30. If your link already has a time in it (?t=90), it's filled in for you.
Why doesn't autoplay work with sound?
Browsers block autoplay with sound, so an embed can only autoplay muted. That's why choosing autoplay also mutes the video.
What is privacy-enhanced mode?
An embed served from youtube-nocookie.com. According to YouTube, it doesn't store information about your visitors unless they play the video, which helps with privacy rules such as the GDPR.
How do I make a YouTube embed responsive?
Leave Responsive size on. The code wraps the player so it fills the width of the page and keeps its shape on every screen.