About the YouTube Embed Code Generator tool
YouTube’s own Share → Embed dialog gives you a fixed 560×315 iframe and only a couple of options. Real websites usually need more: a player that scales with the page, a clip that starts and stops at specific times, a muted autoplay background video, a looping product demo, or a privacy-friendly embed that sets no cookies until the viewer presses play. This YouTube embed code generator builds that code for you.
Paste a video link, a playlist link, or a video link that includes a playlist. Then set a start and end time, turn on autoplay (which automatically adds mute, since browsers block autoplay with sound), hide the controls, loop the video, show captions by default or limit related videos to your own channel. Privacy-enhanced mode switches the domain to youtube-nocookie.com. The responsive option wraps the iframe in a container that keeps a 16:9 ratio at any width; turn it off to set a fixed width and height.
The generated HTML includes a descriptive title attribute for accessibility and optional lazy loading. Code is built locally in your browser; only the optional preview loads the real player from YouTube, and only when you click “Load preview”.
How to use YouTube Embed Code Generator
- Paste a YouTube video or playlist URL into the first box.
- Set a title attribute and, if needed, “Start at” and “End at” times.
- Choose options such as Responsive, Privacy-enhanced mode, Autoplay, Loop and Show player controls.
- Click “Load preview” to test the player with your settings.
- Click “Copy code” and paste the HTML into your website or CMS.
Features
Responsive or fixed size
A 16:9 wrapper using CSS aspect-ratio, or classic width and height attributes.
Start, end, autoplay and loop
Adds the correct player parameters, including the playlist trick YouTube requires for looping one video.
Privacy-enhanced mode
Uses youtube-nocookie.com so YouTube does not set cookies until the visitor plays the video.
Playlist support
Embeds whole playlists via videoseries, or starts on a specific video within a list.
Accessible, lazy-loaded markup
Includes a title attribute and optional loading="lazy" to speed up pages.
When to use it
- Embed a product demo that plays muted and loops on a landing page.
- Show only the relevant 90 seconds of a long webinar in a help article.
- Add a responsive video to a WordPress, Webflow or plain HTML page.
- Embed a full course playlist on a training page.
- Reduce cookies on a site by using YouTube’s privacy-enhanced domain.
Frequently asked questions
How do I make a YouTube embed responsive?
Wrap the iframe in a container with width:100% and aspect-ratio:16/9, and make the iframe fill it. Turn on “Responsive” and the generator writes that code for you.
Why doesn’t my embedded YouTube video autoplay?
Browsers block autoplay with sound. Autoplay only works reliably when the video is muted, which is why this tool adds mute=1 whenever autoplay is on.
How do I loop a single YouTube video?
Add loop=1 and also playlist=VIDEO_ID with the same video ID. The generator adds both automatically when you switch on Loop.
What does privacy-enhanced mode do?
It loads the player from youtube-nocookie.com, which avoids setting YouTube cookies until the visitor interacts with the video. Some tracking can still happen after playback starts.
Can I hide related videos at the end?
Not completely. Since 2018, rel=0 only limits related videos to the same channel. The option in this tool adds rel=0 for that behaviour.
Does this tool contact YouTube?
Building the code happens entirely in your browser. Only the optional preview loads the YouTube player, and only after you click “Load preview”.