YouTube Embed Code Generator
FREE TOOL · NO SIGN-UP
A YouTube embed code generator turns a YouTube link into the iframe code you paste into a website, with your chosen player settings already applied. Paste a video URL or ID into the tool above, set a start time, size, autoplay, loop, captions and privacy-enhanced mode, and copy clean, responsive embed code. It works with standard watch links, youtu.be short links, Shorts and live URLs, and the code works in WordPress, Blogger or plain HTML.
What a YouTube Embed Code Is
An embed code is a small piece of HTML, usually an iframe, that loads YouTube’s video player inside your page. The video stays hosted on YouTube, so you do not pay for bandwidth or storage, but visitors can watch without leaving your site.
YouTube’s own Share, then Embed option gives you a basic iframe. It works, but it has a fixed width and height, so it can overflow on phones, and changing options means editing URL parameters by hand. A generator handles that for you: you tick the options, and it builds the correct embedded player URL with parameters like start, autoplay and loop already in place.
The generated code also includes a title attribute for accessibility, the permissions YouTube’s player expects (autoplay, encrypted media, picture-in-picture, fullscreen and others), and a referrer policy that matches YouTube’s own embed code.
Embedding is how most sites add video to blog posts, product pages, course lessons and landing pages. Done well, it adds useful content without slowing the page down much. Done badly, it can add weight and break layouts on mobile.
Player Options You Can Set
The generator exposes the player parameters most people need. Each option maps to a standard YouTube embed parameter, so the code behaves the same as if you had written it by hand.
Start time, loop and autoplay
Start at lets you begin playback at a specific point. Enter seconds (90) or minutes and seconds (1:30). The tool converts mm:ss into seconds for the start parameter.
End at stops playback at a set second, useful for showing one clip from a longer video.
Loop replays the video when it ends. YouTube only loops a single video when the playlist parameter is set to the same video ID, so the generator adds that automatically.
Autoplay (muted) starts the video as soon as the player loads, with sound off. Browsers block autoplay with sound in most cases, so muting is what makes autoplay work reliably. Use it sparingly, since unexpected video can annoy visitors and uses mobile data.
Controls, captions and fullscreen
Show controls is on by default and displays the play, volume and progress bar. Turning it off hides the controls, which suits background or decorative video but makes the player harder to use.
Captions on asks the player to show closed captions by default when the video has them. It helps viewers watching without sound and makes your content more accessible.
Related videos from same channel only sets rel=0. YouTube no longer lets embeds hide related videos completely, but with this option the suggestions at the end come from the same channel rather than from anywhere on YouTube.
Fullscreen is always allowed in the generated code, so viewers can expand the player.
Privacy-enhanced mode with youtube-nocookie
Privacy-enhanced mode is on by default. It loads the player from youtube-nocookie.com instead of youtube.com. In this mode, YouTube says it does not store information about visitors on your site to personalize their YouTube experience unless they play the video.
This can help with privacy expectations and cookie rules, though it does not remove all tracking once someone presses play. Check your own privacy policy and consent setup with your legal advisor if that applies to your site.
How to Generate an Embed in Four Steps
Paste the YouTube URL or video ID. Any standard format works: youtube.com/watch?v=…, youtu.be/…, youtube.com/shorts/…, youtube.com/live/… or the 11-character ID on its own. The tool confirms the video ID it found.
Set start and end times. Leave them blank to play from the beginning.
Choose the size and options. Pick Responsive 16:9 for most sites, or a fixed size: 560 × 315, 640 × 360, 854 × 480 or 1280 × 720. Add a descriptive title for screen readers and tick the options you want: privacy-enhanced mode, lazy-load, autoplay, loop, controls, captions and related videos.
Copy the code and paste it into your page. Click Copy or Download to save youtube-embed.html. In WordPress, paste it into a Custom HTML block. In Blogger, switch the post editor to HTML view first. In plain HTML, paste it where the video should appear.
On mobile, you can get the video link from the YouTube app’s Share button, then paste it into the generator in your phone’s browser.
Making the Iframe Responsive
A fixed-size iframe, such as 560 × 315, keeps the same width on every screen. On a phone narrower than the iframe, it overflows or forces sideways scrolling.
The Responsive 16:9 option wraps the iframe in a container that keeps a 16:9 aspect ratio and fills the available width. It uses a padding-bottom of 56.25% (9 divided by 16) on the container and positions the iframe absolutely inside it at full width and height. The styles are inline, so you do not need to add any CSS to your theme.
The result scales from a narrow phone to a wide desktop without black bars or overflow. If your theme limits content width, the video simply fills that width.
For vertical Shorts, the 16:9 wrapper will show the video with side bars. You can adapt the wrapper’s padding-bottom to 177.78% for a 9:16 vertical player if you prefer.
Embedded Video and Page Speed
Every YouTube embed loads the player’s scripts and styles, which adds noticeable weight to a page, more so with several videos. Two techniques reduce the impact.
Lazy loading. The Lazy-load option, on by default, adds loading=”lazy” to the iframe. Browsers then wait to load the player until the visitor scrolls near it. This helps most when the video sits below the fold.
Facade loading. A facade shows a lightweight thumbnail image with a play button, and only loads the real player when someone clicks. It saves even more, especially for pages with several videos. Many WordPress performance plugins offer this as a “lazy load YouTube” or “replace iframe with preview image” option.
Avoid placing a heavy autoplay video at the top of a page unless it is essential; it can slow the main content.
Video SEO for Embedded Content
Google can find and index videos embedded from YouTube on your pages. To help it understand the video and show it in search features:
- Put the video on a page where it is a main part of the content, not hidden in a sidebar.
- Add text around it: a heading, a summary or a transcript that explains what the video covers.
- Add VideoObject structured data with the title, description, thumbnail, upload date and embed URL. Build it with the Video Schema Generator.
- For many videos, list them in a video sitemap using the Video Sitemap Generator.
Embedding a video can also keep visitors on the page longer, which is good for user engagement, though that is not a direct ranking factor.
Embed Mistakes to Avoid
Using a fixed size on a responsive site. Choose Responsive 16:9 unless you have a reason not to.
Autoplaying with sound. Browsers block it, and visitors dislike it. The generator always mutes autoplay.
Leaving out the title. Screen reader users get no information about the iframe.
Embedding many videos high on one page. Each one adds weight. Use lazy loading or facades.
Pasting into a visual editor. Rich text editors can strip or mangle iframe code. Use an HTML or code block.
Forgetting the loop playlist. If you build loop code by hand without the playlist parameter, the video will not loop.
Embedding private or restricted videos. If the owner has disabled embedding or made the video private, the player will show an error.
Copyright and When Not to Embed
Embedding uses YouTube’s own player and is allowed by YouTube’s terms of service, as long as the uploader has not disabled embedding. The video stays on YouTube, and the owner keeps control. That said, embedding a video that was uploaded without the copyright owner’s permission can still create legal risk in some situations. Embed from official channels where possible, do not present someone else’s video as your own, and remove an embed if the owner asks.
Embedding Video That Loads Fast
Generate responsive, lazy-loaded embeds here, link viewers to exact moments with the YouTube Timestamp Link Generator, and add markup so search engines understand the video. Find more free tools in the FHSEO Hub free SEO tools collection.
