YouTube embed code generator

Build the iframe with start and end times, privacy mode and the options that are easy to get wrong. Runs in your browser — nothing is sent anywhere.

Why privacy-enhanced mode is on by default

A standard YouTube embed sets tracking cookies the moment your page loads, whether or not anyone presses play. Switching the host to youtube-nocookie.com defers that until playback actually starts, which is usually what you want and makes cookie banners considerably easier to justify. It changes nothing else about how the player behaves.

How to embed a YouTube video

  1. Copy the video's link from YouTube. Regular videos, Shorts, live streams and youtu.be links all work.
  2. Paste it into the box at the top of this page. The options and a preview appear.
  3. Set a start or end time if you need one, pick the options you want, and change the width and height if 560×315 does not suit your layout.
  4. Check the preview, then press Copy and paste the code into your page's HTML. On WordPress and most site builders, use a Custom HTML or Embed block.

Frequently asked questions

How do I embed a YouTube video starting at a specific time?

Type the time into the Start box, either as 1:23 or as plain seconds. The tool converts it to seconds and adds a start parameter to the embed URL. Add an End time too if you only want to show one section.

How do I make an embedded YouTube video autoplay?

Tick Autoplay. The tool also adds mute=1, because browsers block autoplay with sound, so an unmuted autoplay embed usually just sits there. Visitors can turn the sound on themselves.

How do I loop an embedded YouTube video?

Tick Loop. YouTube's player only loops a single video when the embed also has a playlist parameter set to that same video, which is the part people usually miss. The tool adds it for you.

What is youtube-nocookie.com?

It is YouTube's privacy-enhanced embed domain. The player looks and works the same, but YouTube does not set its cookies until someone presses play. It is on by default here; untick it if you want the standard youtube.com embed.

How do I make a YouTube embed responsive?

The code uses a fixed width and height, 560×315 by default, which you can change. To make it scale with the page, set the iframe's width to 100% and its height to auto in your CSS, and give it aspect-ratio: 16 / 9.

Why does my embed say the video is unavailable?

Usually the creator has turned off embedding, or the video is private, deleted or restricted. The preview on this page uses the same code, so if it fails here it will fail on your site too. Nothing in the embed settings can override that.