YouTube Embed Code Generator

Create clean, responsive embed code for any YouTube video — with start time, autoplay, loop and privacy options.

Embed code
Paste a link to generate the code.

Live preview appears here.

Embedding a YouTube video keeps visitors on your page while YouTube handles the streaming. The basic code from YouTube’s Share box works, but it is a fixed 560×315 box that does not fit phones, and it hides useful options like start and end times. This generator builds clean, responsive embed code with all the settings in plain checkboxes, and shows a live preview before you copy it.

How to create your embed code

  1. Paste the YouTube video link – watch, youtu.be, Shorts and live links all work.
  2. Optional: set Start at and End at to show only part of the video.
  3. Tick the options you need: Responsive, Privacy-enhanced mode, Autoplay (muted), Loop, Show controls and Captions on.
  4. Check the live preview, then click Copy code and paste it into your website.

What each option does

OptionParameter in the codeGood to know
Start at / End atstart=85&end=140Times in seconds; you can type 1:25 and the tool converts it
Responsivewidth:100%; aspect-ratio:16/9Fills the column on any screen; untick to set a fixed width and height
Privacy-enhanced modeyoutube-nocookie.comNo YouTube cookies until the visitor presses play
Autoplay (muted)autoplay=1&mute=1Browsers only allow autoplay without sound
Looploop=1&playlist=IDYouTube needs the playlist parameter for a single video to loop
Show controlscontrols=0 when offHiding controls suits background videos, not tutorials
Captions oncc_load_policy=1Shows captions by default if the video has them

The code also includes loading="lazy", so the player only loads when the visitor scrolls near it, and a descriptive title for screen readers.

Where to paste the code

  • WordPress: add a Custom HTML block and paste the code. (The plain YouTube block cannot set start/end or privacy mode.)
  • Blogger: open the post, switch to HTML view, and paste where the video should appear.
  • Wix, Squarespace, Webflow: use the Embed or Code element.
  • Shopify: in a page or product description, click Show HTML (<>) and paste.
  • Plain HTML: paste it inside the page’s <body>, wherever the video belongs.

Embedding Shorts and vertical videos

Shorts can be embedded too – the generator converts a /shorts/ link to a normal embed. Because Shorts are vertical, untick Responsive and set a size such as 315 × 560 so the player is not a wide box with black sides.

Speed and SEO tips

  • Embed only one or two videos per page. Every player loads scripts; too many slow the page down.
  • Write about the video on the page. Search engines cannot watch it, so a short summary, key points or a transcript help the page rank.
  • Use your own thumbnail first on very speed-sensitive pages: show an image and load the player on click. The thumbnail size tool shows and downloads every size of the video’s image.
  • Respect people’s data. Privacy-enhanced mode is a simple win for EU visitors.

Troubleshooting

  • “Video unavailable” – the owner disabled embedding, or the video is private, age-restricted or region-blocked.
  • Autoplay does not start – it must be muted, and some phones still block it in low-power mode.
  • Loop restarts at 0:00 instead of your start time – that is how YouTube’s loop works; for a looping clip, trim the video itself.
  • The player overflows on mobile – make sure Responsive is ticked, or that your theme does not force a fixed height on iframes.

Need a plain link instead of a player? The timestamp link generator creates links that start at a set time. For step-by-step instructions with screenshots for each website builder, read how to embed a YouTube video.

Frequently asked questions

How do I embed a YouTube video on my website?

Paste the video link into the generator, choose the options you want and click Copy code. Then paste the iframe code into your page – in WordPress use a Custom HTML block, in Blogger switch to HTML view, in Wix or Squarespace use an Embed/Code element.

Why does autoplay only work when the video is muted?

Chrome, Safari, Firefox and Edge block videos that start with sound on their own. Muted autoplay is allowed, so the generator turns on mute=1 automatically when you tick Autoplay.

What is privacy-enhanced mode?

It loads the player from youtube-nocookie.com, which does not store YouTube cookies for the visitor until they press play. It looks and works the same, and helps with GDPR-friendly websites.

How do I make the embedded video responsive?

Tick Responsive. The code then uses width:100% and aspect-ratio:16/9, so the player fills its container on phones and desktops without black bars or extra CSS.

Why does my embed say Video unavailable?

The owner may have turned off embedding, the video may be private, age-restricted or blocked in the visitor’s country, or the link may be wrong. Test the code in the live preview first – if it fails there, it will fail on your site too.

Can I embed only part of a video?

Yes. Fill in Start at and End at. The player starts at the first time and stops at the second, which is handy for showing one clip from a long tutorial or stream.

Keep reading