YouTube Embed Code Generator

Paste a YouTube link and choose how the player should behave. You get clean, responsive iframe code that scales on phones, with privacy-enhanced mode switched on by default.

100% freeNo sign-upRuns in your browserWorks on mobile
Player options
Size
Embed code

  

Paste a video link to generate the code.

The preview loads the real YouTube player, so it connects to YouTube only when you click Show preview.

How to use the YouTube Embed Code Generator

  1. Paste the link of the video you want to embed. Watch, youtu.be, Shorts and live links all work.
  2. Pick player options such as autoplay, loop, captions, start and stop times.
  3. Keep Responsive so the player fills its container on every screen, or switch to a fixed width and height.
  4. Click Show preview to try the player, then Copy code and paste it into your page’s HTML.

Features

  • Responsive 16:9, 9:16, 4:3 or 1:1 wrapper that works in every browser
  • Privacy-enhanced youtube-nocookie.com domain on by default
  • Start and stop times in mm:ss, h:mm:ss or seconds
  • Autoplay (muted, as browsers require), loop, captions and controls options
  • Accessible title and lazy loading for faster pages
  • Live preview that loads only when you ask for it

What the embed code does

A YouTube embed is an <iframe>, a window on your page that loads YouTube’s player for one video. The address inside it, such as https://www.youtube-nocookie.com/embed/VIDEO_ID?start=90, tells the player which video to show and how to behave. Everything you choose in this tool becomes a parameter on that address or an attribute of the iframe.

Player parameters explained

OptionParameterEffect
Start at / Stop atstart, endPlay only part of the video, in seconds
Autoplayautoplay=1Starts playing when the player loads
Start mutedmute=1Required for autoplay in modern browsers
Hide controlscontrols=0Removes the control bar
Looploop=1&playlist=VIDEO_IDRepeats the video; the playlist value is required
Captions oncc_load_policy=1Shows captions by default when available
Related from this channelrel=0End-screen suggestions come from the same channel

Two behaviors surprise people. First, autoplay with sound is blocked by Chrome, Safari and Firefox unless the visitor has interacted with your site, so the tool adds mute=1 whenever autoplay is on. Second, since 2018 rel=0 no longer hides suggestions completely; it limits them to videos from the same channel.

Privacy-enhanced mode

Using the youtube-nocookie.com domain switches the player to YouTube’s privacy-enhanced mode, which YouTube describes as preventing views of embedded videos from influencing the viewer’s YouTube recommendations and browsing experience. It is a sensible default for sites with privacy commitments, though it does not remove the need for a cookie notice where the law requires one: once a visitor presses play, YouTube’s services are still involved.

Making the embed responsive

A fixed 560 × 315 iframe overflows on phones. The responsive code wraps the iframe in a container whose height is set as a percentage of its width with padding-bottom: 56.25% for 16:9 (9 ÷ 16), 75% for 4:3 and 177.78% for vertical Shorts. The iframe is then stretched to fill the container, so the player keeps its shape at any width. Add a maximum width to stop it from becoming huge on wide screens; for Shorts, around 360 px looks natural.

Performance tips

  • Lazy loading (loading="lazy") delays the player until the visitor scrolls near it, which speeds up the initial page load.
  • Avoid several autoplaying videos on one page; they compete for bandwidth and annoy visitors.
  • Give each iframe a meaningful title so screen-reader users know what the frame contains.

Want to share a moment instead of embedding? Create a link that opens at a set time with the YouTube Timestamp Link Generator, or grab the cover image with the YouTube Thumbnail Downloader.

Frequently asked questions

Why does my embedded video not autoplay?

Browsers block autoplay with sound. Turn on autoplay here and the code also adds mute=1, which browsers allow. Some browsers and data-saver settings may still block it.

What is youtube-nocookie.com?

It is YouTube’s privacy-enhanced embed domain. The player works the same, but YouTube says views in this mode do not influence the viewer’s recommendations on YouTube.

How do I make a YouTube embed responsive?

Keep the Responsive option selected. The code wraps the iframe in a container that keeps a 16:9 shape (or 9:16 for Shorts) at any screen width.

Can I hide related videos at the end?

Not completely. Since 2018 rel=0 only limits suggestions to videos from the same channel. Using a start and stop time can keep viewers focused on the part you want.

Can I embed a playlist?

Yes. Paste a video link that includes a list= parameter and keep “Include the playlist” ticked; the player will continue through the playlist.

More social media tools

Other free tools you might need next.

View all 8