Generate custom HTML iframe embed code for any YouTube video — with autoplay, loop, start time, responsive mode, privacy settings, and more.
The YouTube Embed Code Generator creates custom HTML <iframe> code for embedding YouTube videos on your website, blog, or landing page. Unlike YouTube's built-in share button, this tool gives you full control over player behavior — autoplay, loop, start/end times, privacy mode, related videos, annotations, responsive sizing, and more.
Responsive mode: Always enable for blogs and CMS pages. It uses a CSS padding trick to maintain 16:9 ratio on all screens. When on, width/height inputs are ignored.
Privacy mode: Loads from youtube-nocookie.com — recommended for GDPR compliance. No tracking cookies until the user interacts.
Autoplay + Mute: Browsers block autoplay with sound. Enable Mute alongside Autoplay — the tool warns you if you forget.
Hide Related Videos: On by default via rel=0. Keeps suggestions limited to the same channel at the end.
Loop warning: Loop requires autoplay to work reliably in most browsers. The tool will warn you if loop is on without autoplay.
End time: YouTube's end= parameter is not strictly enforced in all players — treat it as a soft stop.
Video not loading in preview
Some videos are restricted by the uploader and cannot be embedded. If the preview shows "Video unavailable", the video owner has disabled embedding.
Autoplay not working
Chrome, Safari, and Firefox all block autoplay with sound. Enable Mute alongside Autoplay for reliable auto-playback.
Loop not working
Loop works most reliably with Autoplay also enabled. The tool sets the required playlist parameter automatically.
Embed looks too small
Enable Responsive mode so it fills its container, or disable it and set a custom width/height.