How to embed a YouTube video
- Paste a YouTube video, Shorts or playlist link, or a video ID, into the link box.
- Set an optional start and end time. A timestamp already in the link is filled in automatically.
- Tick the options you need: privacy-enhanced mode, controls, autoplay, mute, loop, captions, fullscreen and lazy-loading.
- Untick Responsive wrapper if you want a fixed width and height instead.
- Check the live preview, then copy the embed code or just the embed URL.
What you can do with Embed Code Generator
- Responsive wrapper
- Wraps the iframe in a container that keeps a 16:9 shape at any width, or 9:16 for Shorts links, so it fits phones and wide layouts.
- Start and end times
- Play only a segment by entering start and end times in m:ss or h:mm:ss; the tool converts them to seconds.
- Privacy-enhanced mode
- Uses the youtube-nocookie.com domain, YouTube's privacy-enhanced embed mode, which reduces tracking of visitors who haven't played the video.
- Autoplay that works
- Adds autoplay and playsinline together, and reminds you to start muted because browsers block autoplay with sound.
- Loop and playlists
- Loops a single video correctly by adding the playlist parameter, and keeps playlist links so the whole list plays.
- Live preview
- The embedded player updates as you change options, so you can test the result before pasting it into your site.
YouTube embed parameters and responsive iframes
A YouTube embed is an iframe pointing to youtube.com/embed/VIDEO_ID, and its behavior is controlled with URL parameters. The most useful are start and end (in seconds), autoplay=1, mute=1, loop=1, controls=0, cc_load_policy=1 to show captions, and rel=0. Since 2018, rel=0 no longer hides related videos; it limits them to videos from the same channel. Looping a single video only works when you also pass playlist with the same video ID, which this generator adds for you.
The default 560×315 iframe has a fixed size, which overflows on phones. The responsive version used here puts the iframe inside a container with padding-bottom set to 56.25 percent, which is 9 divided by 16, so the player scales with its parent and keeps the right shape. Lazy-loading delays the player until it nears the viewport, which helps page speed. Most browsers block autoplay unless the video starts muted, so pair autoplay with mute when it must play on its own.
Frequently asked questions
How do I embed a YouTube video on my website?
Paste the video link here, choose your options and copy the embed code. Then paste it into your page's HTML, or into a custom HTML or embed block in WordPress, Webflow, Squarespace, Wix and similar site builders. The responsive version adapts to any screen width.
Why won't my embedded YouTube video autoplay?
Chrome, Safari, Firefox and Edge block autoplay with sound by default. Tick both Autoplay and Start muted for reliable autoplay. Also make sure the video owner allows embedding, because some videos can only be played on YouTube itself.
What is youtube-nocookie.com?
It is the domain for YouTube's privacy-enhanced embed mode. Videos play the same way, but the player is designed to reduce tracking of visitors, especially before they press play. It's a sensible default for privacy-conscious sites, though on its own it isn't a guarantee of legal compliance.
Can I embed a YouTube video to start at a specific time?
Yes. Enter the time in the Start at box, for example 1:30, and the tool adds start=90 to the embed URL. You can also set an end time so the player stops at the end of the segment you want to show.
Can I embed YouTube Shorts?
Yes. Paste a Shorts link and the tool switches to a vertical 9:16 responsive wrapper, capped at 360 pixels wide so it doesn't take over the page. The Short plays in the standard YouTube embed player.