YouTube Embed Code Generator
Build a ready-to-paste <iframe> embed snippet from any YouTube URL, with size, autoplay, controls and privacy-mode options.
This guide is not yet available in your language and is shown in English.
Tool guide
What this tool does
YouTube Embed Code Generator turns any YouTube video URL into a complete, ready-to-paste <iframe> embed snippet, with configurable width/height, autoplay, player controls visibility and YouTube’s privacy-enhanced (youtube-nocookie.com) embed mode, with a live preview before you copy it.
Embedding a YouTube video on a website means hand-writing an <iframe> tag with the right video ID, dimensions and parameters, easy to get subtly wrong, especially the privacy-enhanced mode or a specific start time.
This tool builds that complete embed snippet for you from any pasted YouTube URL, with configurable width, height, autoplay, controls visibility and privacy-enhanced (youtube-nocookie.com) mode, showing a live preview so you can confirm it works before copying the code.
How to use YouTube Embed Code Generator
- Paste a YouTube video URL (a timestamp in the URL carries through automatically).
- Set your desired width and height.
- Toggle autoplay, controls visibility, and privacy-enhanced mode as needed.
- Preview the embedded player, then copy the generated code.
Tips for better results
- Privacy-enhanced mode (youtube-nocookie.com) is what YouTube itself recommends for sites that want to avoid setting viewing-related cookies on a visitor’s device unless they actually press play, useful for GDPR/cookie-consent-conscious sites.
- Most browsers block autoplaying video with sound regardless of the autoplay setting, so autoplay-enabled embeds typically start muted until the viewer interacts with the player.
- If your source URL includes a timestamp (a ?t= or &start= parameter), it’s automatically carried through into the generated embed, the video will start at that point rather than from the beginning.
- The generated iframe includes a comprehensive "allow" attribute (covering fullscreen, picture-in-picture, encrypted media, and more) so modern browser features work correctly inside the embed.
Common use cases
- Adding an embedded YouTube video to a website, blog post, or documentation page.
- Generating a privacy-conscious embed that avoids setting cookies before a visitor opts to play the video.
- Embedding a video that starts at a specific, relevant timestamp rather than the beginning.
- Quickly previewing how an embedded player will look at different dimensions before adding the code to a site.
Common mistakes to avoid
- Expecting autoplay with sound to work reliably; browsers widely restrict autoplaying audio, so an autoplay embed usually starts muted regardless of this setting.
- Using the standard youtube.com embed domain when a privacy-enhanced, cookie-conscious embed was actually required for the site’s compliance needs; toggle privacy-enhanced mode on for that case.
- Setting the iframe’s width/height disproportionately to the video’s natural 16:9 aspect ratio, producing letterboxing or a stretched video inside the player frame.
Frequently asked questions
What’s the difference between youtube.com and youtube-nocookie.com embeds?
youtube-nocookie.com is YouTube’s privacy-enhanced embed domain, which YouTube says avoids storing viewing-related cookies on a visitor’s device unless they actually play the video, useful for cookie-consent-conscious sites.
Does a timestamp in my source URL carry into the embed?
Yes, a ?t= or &start= parameter in the pasted URL is automatically detected and added to the generated embed code, so the embedded video starts at that same point.
Why won’t autoplay play with sound?
Most modern browsers restrict autoplaying video with audio as a user-experience protection; enabling the autoplay option here typically still results in a muted start until the viewer interacts with the player.
Is the embed code generated locally?
Yes, the video ID is extracted and the iframe snippet built entirely in your browser; only the preview iframe itself then loads YouTube’s player directly, as any embed would.
Feedback & suggestions
Help us improve YouTube Embed Code Generator. We read every message.