BYTETOOLS

YouTube Embed Code Generator

Generate a YouTube iframe embed with start and end times, autoplay, loop, privacy-enhanced mode and a responsive aspect-ratio wrapper for any page.

Embed code

Paste a YouTube link above and the iframe code, player URL and a live preview appear here.

What is the YouTube Embed Code Generator?

Paste any YouTube link and get the iframe you need. The video ID is extracted from every URL shape — the watch page, a youtu.

  • Extracts the video ID from watch, youtu.be, Shorts, embed, live and playlist URLs
  • Start and end times accepted as seconds, minutes and seconds, or hours
  • Privacy-enhanced youtube-nocookie.com host option, on by default
  • Responsive aspect-ratio wrapper, or a fixed width with the height calculated
  • Looping handled with the one-item playlist trick YouTube actually requires
  • Nothing is loaded from YouTube here — the preview is a plain layout box

How to use the YouTube Embed Code Generator

  1. 1

    Paste a YouTube URL, or just the 11-character video ID.

  2. 2

    Set start and end times in seconds or minutes and seconds to clip the playback.

  3. 3

    Tick the player options: responsive wrapper, privacy mode, autoplay, loop, controls.

  4. 4

    Copy or download the embed code and paste it into your own page.

About the YouTube Embed Code Generator

Paste any YouTube link and get the iframe you need. The video ID is extracted from every URL shape — the watch page, a youtu.be short link, a Shorts URL, an existing embed, a live link or a bare 11-character ID — and a playlist ID is picked up from the list parameter whenever one is present.

Toggle the player options you want: privacy-enhanced hosting on youtube-nocookie.com, autoplay with the muting browsers insist on, looping, hidden controls, related videos restricted to the same channel, and start and end times entered as plain seconds or as minutes and seconds. The iframe title is editable, because screen readers announce it to your visitors.

The responsive option wraps the player in a div with a CSS aspect-ratio rule so it scales with its container, or you can give a fixed pixel width and let the height be derived from the ratio. The preview is a layout box only — this page never loads anything from YouTube, and the code is built 100% locally in your browser.

Frequently asked questions

How do I make a YouTube embed responsive?

Wrap the iframe in a container with a CSS aspect-ratio and let the iframe fill it absolutely, instead of setting fixed width and height attributes. Tick the responsive wrapper option here and both the div and the CSS are generated for you.

How do I make a YouTube video start at a specific time?

Add a start parameter holding the offset in seconds to the embed URL, and an end parameter to stop playback early. Type 1:30 or 90 into the start box here and the correct parameter is written into the iframe for you.

What is youtube-nocookie.com?

It is YouTube's privacy-enhanced host, which avoids setting personalised-advertising cookies until a visitor actually plays the video. It is the better default for most sites and is switched on here, though it does not make the embed completely cookie-free.

Why does my looping YouTube embed not loop?

A single video only loops when it is also passed as a one-item playlist, so the loop parameter has to be paired with a playlist parameter holding the same video ID. Tick Loop the video and this tool adds both automatically.

How do I stop YouTube showing other channels at the end?

Set the rel parameter to zero, which restricts suggested videos to the same channel rather than removing them entirely — YouTube stopped honouring full removal years ago. Untick the related-videos option to add that parameter.

Related tools