ThumbnailsGrabber.com

YouTube Embed Code Generator

Your embed code

Open embed URL

Preview: the video's thumbnail at the chosen shape. Click the button to load the real player with your options.

The code is built on this page from the link you paste; nothing is sent to a server. The preview shows the video's thumbnail and loads the YouTube player only when you click it.

This YouTube embed code generator turns any video, Shorts, youtu.be, or playlist link into an <iframe> you can paste into a web page. It produces the same embed YouTube's own Share panel gives you, and adds the options that panel leaves out: a responsive 16:9 or 9:16 frame that fills its container, an end time as well as a start time, muted autoplay, loop, hidden controls, captions on by default, lazy loading, and privacy-enhanced mode on www.youtube-nocookie.com. The video ID is extracted from the link, the thumbnail confirms you have the right video, and the player loads only when you ask for it.

How to get a YouTube embed code

  1. Paste the link. Any format works: youtube.com/watch?v=ID, youtu.be/ID, youtube.com/shorts/ID, a live or embed URL, or a playlist link with list=. A ?t=90 or &t=1m30s in the link fills the start time for you.
  2. Choose the size. Responsive 16:9 is the right choice for almost every website: the player is as wide as the column it sits in and keeps its shape on phones. The fixed sizes give an iframe with width and height attributes, the way YouTube's panel does.
  3. Set the options. Start and end times, autoplay, loop, controls, captions, related videos, and privacy-enhanced mode. The code refreshes as you change them.
  4. Copy and paste. Click Copy code and paste it into your page's HTML: a Custom HTML block in WordPress, an Embed or Code element in Squarespace, Wix, or Webflow, a raw HTML block in Notion or Ghost, or the template of a hand-built page.

What each option changes in the embed URL

Every option maps to one player parameter on the /embed/VIDEO_ID URL, so you can also edit the code by hand later.

OptionParameterWhat it does
Start atstart=90Begins playback at that second. The generator converts 1:30 or 1m30s for you.
End atend=165Stops playback at that second, measured from the start of the video, not from the start time.
Autoplay (muted)autoplay=1&mute=1Starts the video on load. Browsers only allow this when the sound is off, so mute is added with it.
Looploop=1&playlist=VIDEO_IDReplays the video when it ends. A single video only loops when it is also listed as its own playlist, which is why both parameters appear.
Hide player controlscontrols=0Removes the play bar, volume, and settings. Visitors can still click the video to pause and play it.
Captions oncc_load_policy=1Shows captions when the video starts, even for visitors who have captions turned off in their YouTube settings.
Related videos from this channel onlyrel=0When the video ends or is paused, the suggestions come from the same channel instead of all of YouTube. Related videos cannot be removed entirely.
Privacy-enhanced modehost www.youtube-nocookie.comServes the player from the no-cookie domain; see below.
Lazy loadloading="lazy" on the iframeThe browser defers the player until the embed scrolls near the viewport, so a video far down the page costs nothing until then.

Two parameters you may see in older tutorials no longer do anything: modestbranding was retired by YouTube in August 2023 and the logo shows regardless, and showinfo stopped working in 2018. The generator leaves both out. playsinline=1 is included so iPhones play the video inside your page instead of forcing full screen.

Responsive YouTube embed: how the wrapper works

An iframe has no natural size, so a bare width="560" height="315" embed overflows a narrow phone column or sits small in a wide one. The responsive option wraps the iframe in a block that keeps the 16:9 ratio and lets the player fill it:

<div style="position:relative;width:100%;aspect-ratio:16/9">
  <iframe src="https://www.youtube-nocookie.com/embed/VIDEO_ID"
          style="position:absolute;inset:0;width:100%;height:100%;border:0"
          title="YouTube video player" loading="lazy"
          allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
          referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div>

aspect-ratio has shipped in every major browser since 2021. If you must support browsers older than that, replace it with padding-bottom:56.25% on the wrapper (9 divided by 16, as a percentage of the width) and keep the absolutely positioned iframe; the result is identical. To stop the player from growing past a certain width, add max-width:960px;margin:0 auto to the wrapper.

Privacy-enhanced mode and cookie banners

With privacy-enhanced mode on, the player loads from www.youtube-nocookie.com. YouTube's own description of the setting is that it does not store information about visitors on your website unless they play the video. Nothing about the player, the video quality, or the parameters changes, which is why the generator turns it on by default. If your site runs a consent banner, the cleanest pattern is to combine this mode with the click-to-load thumbnail facade: the page shows only the thumbnail image until the visitor clicks, and the iframe, and any storage it uses, exists only after that click.

Autoplay, start times, and loops

Browsers refuse to start video with sound on their own, so an autoplaying embed must be muted; the generator adds mute=1 whenever you tick autoplay, and the iframe's allow attribute grants the autoplay permission the player needs. Phones may still wait for a tap, particularly with a data-saving mode on. A start time is the reliable alternative when you want visitors to land on the moment that matters: the player shows that frame as its poster and begins there on click. An end time stops the video at a second count taken from the beginning of the file, so a clip from 1:30 to 2:45 is start=90&end=165. Loop replays that same range.

Embedding Shorts and playlists

A Short is an ordinary video with a vertical frame, and /embed/ID plays it like any other. Choose the 9:16 size so the player matches the video; in a 16:9 frame the Short plays pillarboxed, with black bars on both sides. For a playlist, paste a link that contains list=: with no video ID the embed uses /embed/videoseries?list=PLAYLIST_ID and starts on the first item; with a video ID as well, that video plays first and the rest of the playlist follows in the player's queue.

Page speed: the embed is not free

Every YouTube iframe loads the full player on your page, scripts and all, whether or not anyone presses play, and a page with three embeds pays three times. Two things keep the cost down. Lazy load, on by default here, postpones each player until it scrolls close to the screen. For the embed at the top of a page, or for pages with many videos, use the thumbnail as a poster and build the iframe only on click; the embed a YouTube thumbnail guide has the ten-line facade script, and the thumbnail grabber gives you the 1280x720 image to use as that poster.

When the embed shows "Video unavailable"

If the thumbnail preview on this page loads but the player refuses, the video's owner has most likely turned off Allow embedding in YouTube Studio; the embed then shows Video unavailable, Watch on YouTube, and no parameter changes that. Private videos cannot be embedded at all, age-restricted videos refuse to play outside youtube.com, and a video removed for copyright is gone from embeds too. Unlisted videos embed normally, which makes an unlisted upload plus an embed the usual way to put a video on a website without listing it on the channel. A thumbnail that fails to load usually means the ID is wrong or the video is gone; the thumbnail not showing guide walks through the other causes.

The video ID, and where it comes from

Every YouTube video has an 11-character ID made of letters, digits, hyphens, and underscores, and the embed URL is nothing more than https://www.youtube.com/embed/ followed by that ID. The generator reads it from the v= parameter of a watch link, from the path of a youtu.be, /shorts/, /live/, or /embed/ link, and shows it under the code so you can reuse it elsewhere, for example in the thumbnail URL patterns that turn the same ID into every image YouTube stores for the video.

Frequently asked questions

How do I get the embed code from YouTube itself?

Open the video on youtube.com, click Share under the player, then Embed, and copy the iframe from the panel. YouTube's panel only offers a start time and two checkboxes (player controls and privacy-enhanced mode) at a fixed 560x315 size. This generator produces the same iframe and adds responsive sizing, an end time, autoplay, loop, captions, lazy loading, and Shorts and playlist links.

How do I make a YouTube embed responsive?

Wrap the iframe in a block that keeps a 16:9 ratio and let the iframe fill it. The responsive option here uses a div with width: 100% and aspect-ratio: 16 / 9, with the iframe positioned to cover it. Every current browser supports aspect-ratio; for very old browsers the older trick is padding-bottom: 56.25% on the wrapper, which is the same 9/16 ratio expressed as a percentage of the width.

What is privacy-enhanced mode?

It serves the player from www.youtube-nocookie.com instead of www.youtube.com. YouTube states that in this mode it does not store information about visitors on your website unless they play the video. It is the setting to use when your site has a cookie banner or serves visitors in the EU, and it changes nothing about how the video looks or plays.

Why does my autoplay embed not autoplay?

Browsers block video with sound from starting on its own. An embed only autoplays when it is muted, so this generator adds mute=1 whenever you tick autoplay. On phones, and in some browsers with data saving on, even a muted video may wait for a tap. Autoplay also needs the autoplay permission in the iframe's allow attribute, which the code includes.

How do I start a YouTube embed at a specific time?

Enter the start time as seconds, m:ss, or h:mm:ss. The generator adds start=SECONDS to the embed URL. If you paste a link that already has a ?t= or &t= parameter, the start field is filled from it. An end time works the same way with end=SECONDS, and the player stops there.

Can I embed a YouTube Short?

Yes. A Short is a normal video with an 11-character ID, and youtube.com/embed/ID plays it in any iframe. Pick the 9:16 size so the player matches the vertical video; a 16:9 frame plays it with black bars on both sides. The link format youtube.com/shorts/ID is parsed automatically.

Why does the embed say Video unavailable?

The most common cause is that the video's owner turned off Allow embedding in YouTube Studio; the player then shows Video unavailable, Watch on YouTube. Private videos, videos removed for copyright, and age-restricted videos also refuse to play in an embed. Unlisted videos embed normally. The thumbnail preview on this page loads for any public video, so a preview that appears with a player that refuses usually means embedding is disabled.