Skip to content
YouTubePre

YouTube embed code generator

Build clean, responsive embed code with the options YouTube’s share dialog does not show — privacy mode, end time, loop and lazy loading.

How to use it

  1. 1

    Paste the video link.

  2. 2

    Choose options: start/end time, autoplay, loop, controls, captions, privacy mode.

  3. 3

    Copy the HTML and paste it into your page or CMS.

What the options do

  • Privacy-enhanced mode uses youtube-nocookie.com, which does not store viewing cookies until the visitor plays the video.
  • Responsive keeps a 16:9 shape at any width using CSS aspect-ratio.
  • Lazy loading delays the iframe until it is near the viewport — a large performance win for pages with videos below the fold.
  • Loop repeats the video (YouTube requires the playlist parameter for this, which the generator adds).
  • Autoplay only works when the video is muted, due to browser autoplay policies — the generator mutes it for you.

Keep your page fast

A YouTube iframe loads around a megabyte of scripts. If the video is not the first thing on the page, use lazy loading, or the lightweight "click to load" snippet — it shows the thumbnail and only loads the player when clicked, which keeps Core Web Vitals green.

Frequently asked questions

How do I make a YouTube embed responsive?

Set the iframe to width 100% with CSS aspect-ratio: 16 / 9 and no fixed height. The generated code does this.

How do I make an embedded YouTube video loop?

Add loop=1 together with playlist=VIDEO_ID to the embed URL. Enable Loop in the generator and it is added for you.

Why does autoplay not work?

Browsers block autoplay with sound. Autoplaying embeds must be muted (mute=1).

What is privacy-enhanced mode?

Embeds from youtube-nocookie.com do not use viewing information to personalise the visitor’s experience unless they play the video.

More free tools

Practice with any video