Popular right now

More

YouTube Embed Code Generator

Pick your player options and copy ready-made YouTube embed HTML.

Ready to useFree · No sign-up

Player

HTML

Parameters follow Google's YouTube player parameters reference; privacy-enhanced mode is described in YouTube's embedding help. The code keeps referrerpolicy="strict-origin-when-cross-origin", which YouTube recommends so embeds can identify the site they run on.

The code is built on your device. Nothing loads from YouTube unless you press Load preview.

Works in your browser. No account needed.

Advertisement

Frequently asked questions

Why doesn't autoplay work unless the video is muted?

Browsers generally block videos from playing with sound before the visitor interacts with the page, while muted autoplay is allowed. That is why ticking Autoplay also adds mute=1. Google's parameter reference also notes that with autoplay enabled, playback data is collected and shared as soon as the page loads.

Can I hide related videos at the end?

Not completely. Since September 25, 2018, related videos can no longer be switched off in the embedded player. Setting rel=0 limits them to videos from the same channel as the one that just played, which is the closest option YouTube offers.

What does privacy-enhanced mode actually do?

It serves the player from youtube-nocookie.com. According to YouTube Help, views in this mode are not used to personalize the viewer's YouTube experience or advertising outside your site, and any ads shown in the player are non-personalized. The player is still YouTube's, so it is not the same as loading nothing from Google; if a visitor clicks through to YouTube, YouTube's normal policies apply there.

How do I make a single video loop?

Add loop=1 together with playlist set to the same video ID — Google's documentation says looping a single video in an iframe embed needs both. The generator adds the playlist parameter automatically when you tick Loop.

How do I make the embed responsive?

Keep Responsive 16:9 ticked. The iframe is placed in a wrapper div with aspect-ratio: 16/9 that fills the width of its container, up to the maximum width you set, so a 16:9 video scales on phones without black bars or cropping. Untick it for a fixed width and height instead; YouTube requires the player to be at least 200 by 200 pixels.

Does this page contact YouTube?

Not unless you ask it to. The HTML is assembled in your browser from the video ID and your settings, and no thumbnail or player is loaded. The preview only loads YouTube's player after you press Load preview.

About this tool

This generator builds the iframe code YouTube's embedded player expects, with the options set as URL parameters from Google's official player parameter reference. Start and end take a time in any common format and become start= and end= in seconds; both are measured from the beginning of the video. Autoplay adds autoplay=1 and mute=1, loop adds the playlist parameter it needs, controls=0 hides the control bar, cc_load_policy=1 shows captions by default, playsinline=1 keeps playback inline on iPhones, and rel=0 limits the related videos shown to the same channel.

Privacy-enhanced mode swaps the host to youtube-nocookie.com. YouTube describes it as keeping views in the embed from influencing the viewer's YouTube recommendations and ad personalization; it does not stop the visitor's browser from connecting to YouTube when the player loads. The generated code also includes referrerpolicy="strict-origin-when-cross-origin", which YouTube recommends so the embedded player can identify the site it runs on, plus the allow list YouTube's own Share > Embed code uses and allowfullscreen.

For layout, the responsive option wraps the iframe in a div that keeps a 16:9 shape at any width, using the CSS aspect-ratio property that current browsers support. Fixed mode keeps plain width and height attributes; YouTube's minimum player size is 200 × 200 pixels, and it recommends at least 480 × 270 for 16:9. A descriptive title attribute helps screen reader users, and loading="lazy" lets the browser wait until the player is near the visible area, which saves bandwidth on long pages.

The page is careful about outside requests: the code is put together locally from the video ID and your choices, and no thumbnail, script or player loads from YouTube until you press Load preview. Parameters YouTube has retired, such as modestbranding and showinfo, are left out because they no longer do anything.

Related tools

You might also need