YouTube Embed Code Generator

Create YouTube embed code for your website with a live preview. Make the player responsive, set start and end times, autoplay, loop and more.

Size
Options

Embed code

Preview

How to embed a YouTube video

  1. Paste the video or playlist link into the generator.
  2. Choose your options. Responsive size is best for most websites because the player fills its container on any screen.
  3. Copy the code and paste it into your page's HTML, or into an "HTML" or "Custom code" block in WordPress, Wix, Squarespace, Webflow or Shopify.

What each option does

OptionParameterWhat it does
ResponsiveCSSKeeps the player at 16:9 and scales it to fit any screen width.
Start / endstart, endPlays only part of the video, in seconds.
Autoplayautoplay=1Starts playing on load. Browsers only allow this when the video is muted, so the generator adds mute=1.
Looploop=1Replays when finished. For a single video this also needs playlist=VIDEO_ID, which is added for you.
Controlscontrols=0Hides the player's control bar.
Captionscc_load_policy=1Turns captions on by default, where available.
Privacy-enhancedyoutube-nocookie.comYouTube doesn't store viewing information about visitors unless they play the video. Recommended for GDPR-conscious sites.
Lazy loadloading="lazy"Delays loading the player until it's near the screen, which makes your page faster.

Frequently asked questions

How do I make a YouTube embed responsive?

Select "Responsive" in the generator. It wraps the iframe in a container with a 16:9 aspect ratio and sets the player to 100% width, so it resizes with the page.

Why doesn't autoplay work?

Browsers block autoplay with sound. Autoplaying embeds must be muted. The generator adds mute=1 automatically when you tick Autoplay.

Can I embed a YouTube playlist?

Yes. Paste a link that contains list= (a playlist page or a video inside a playlist) and the generator creates a playlist embed.

Why does my embed say "Video unavailable"?

The uploader may have disabled embedding, or the video is private, age-restricted or blocked in your region. Only the uploader can change these settings.

Can I hide related videos at the end?

Not completely. Since 2018 YouTube always shows related videos when an embed finishes. It limits them to the same channel if you add rel=0, which the generator includes by default.

More free YouTube tools