Free Tool
4.9/5

Free YouTube Embed Code Generator

Paste any YouTube URL and get a responsive iframe you can paste anywhere. Start and end times, autoplay with the mute it needs, a loop that actually loops, and the no-cookie host.

This tool writes HTML you paste into a page. Want a shareable link that starts at a moment instead? That is the YouTube Timestamp Link Generator, which uses t= rather than start=. Just shortening a video URL? Use the YouTube Link Shortener.

Any form works: watch, youtu.be, Shorts, Live, embed, or playlist. A t= or start= already on the URL prefills the start time below.

Whole seconds only. The player seeks to the nearest keyframe, so it can land up to about two seconds early.

Counted from 0:00 of the video, not from your start time. Leave blank to play to the end.

Player options

Embeds cannot travel in an email

Newsletters, PDFs, and chat apps strip iframes, so the video has to go out as a link there. Shorten it with Flyn and see total clicks free on every placement. Country, device, and referrer breakdowns come with Pro.

Shorten for free

How to Generate YouTube Embed Code in 3 Steps

Step 1: Paste a YouTube URL and pick your options, YouTube Embed Code Generator screenshot
1

Paste a YouTube URL and pick your options

Every real URL form works: watch, youtu.be, Shorts, Live, embed, playlist pages, the nocookie host, and a bare 11-character video ID. Set a start and end time in any format (2:15, 135, 1h2m3s), then tick what the player should do. If the URL already carried a t= or start=, we prefill the start time for you.

Step 2: Copy the generated iframe, YouTube Embed Code Generator screenshot
2

Copy the generated iframe

You get the bare embed URL and a full HTML block with the responsive wrapper, the allow list YouTube itself ships, a referrer policy, and a title attribute for screen readers. When Loop forever is on we write loop=1 and playlist set to the same video ID, because loop=1 alone does nothing on a single video. The live preview runs your exact parameters.

Step 3: Paste it into your page and track the link version, YouTube Embed Code Generator screenshot
3

Paste it into your page and track the link version

Drop the block into any HTML page, template, or custom HTML widget and it fills its container at a 16:9 ratio on every screen size. Then, for every place the video goes out as a link instead of an embed, mint a Flyn short link per placement so the click counts tell you which one actually sends people to the video.

What a YouTube Embed URL Is Actually Made Of

Every YouTube embed is the same three pieces: a host, the path /embed/ plus the 11-character video ID, and a query string of player parameters. The host is normally www.youtube.com, and swapping it for www.youtube-nocookie.com is all that privacy mode does. The video ID is the same 11 characters that appear after v= on a watch page, after the slash on a youtu.be link, and after /shorts/ or /live/ on those pages, which is why this tool accepts every one of those forms and pulls the same ID out of all of them.

The query string is where the behaviour lives, and it is also where almost every embed goes wrong. Parameters are plain key and value pairs joined with an ampersand, they take whole numbers rather than 1m30s style notation, and unknown or deprecated parameters fail silently: the player just ignores them and plays anyway. That silence is the whole problem. A missing mute, a lonely loop=1, or a t= where start= belongs produces a player that works fine except for the one thing you wanted, and no error message anywhere tells you why.

One more piece sits outside the URL: the iframe attributes. The allow list (accelerometer, autoplay, clipboard-write, encrypted-media, gyroscope, picture-in-picture, web-share) is what YouTube ships in its own share dialog, and dropping the autoplay entry from it will block autoplay no matter what the URL says. The allowfullscreen attribute is what lets the fullscreen button work at all, and the title attribute gives screen readers something to announce instead of the word iframe. This generator writes all of them, with title set to a placeholder you should replace with the real video title.

The loop Trap: Why loop=1 On Its Own Does Nothing

This is the most valuable thing on this page, so it gets its own section. If you add loop=1 to a single-video embed and nothing else, the video plays once and stops. Not sometimes, not on certain browsers: always. YouTube documents the fix directly in its player parameter reference: to loop a single video you must set loop=1 and also set the playlist parameter to the same video ID that is already in the URL path.

The reason is that the loop parameter was designed for playlists. It tells the player to restart the queue once the queue is exhausted, and a bare single-video embed has no queue to restart. Repeating the video ID in the playlist parameter turns that embed into a one-item queue, and now there is something for loop=1 to send the player back to the start of.

<!-- Plays once, then stops. loop=1 is silently ignored. -->
<iframe src="https://www.youtube.com/embed/aBcD3fGhIjk?loop=1"></iframe>

<!-- Loops forever. playlist repeats the SAME id that is in the path. -->
<iframe src="https://www.youtube.com/embed/aBcD3fGhIjk?loop=1&playlist=aBcD3fGhIjk"></iframe>

Two follow-on details worth knowing. First, a looping hero video usually wants autoplay=1, mute=1, and controls=0 as well, and the autoplay half will not fire without the mute. Second, if the video you pasted already belonged to a playlist, loop and list fight over the same queue, so this generator turns the Keep playlist option off while Loop forever is on rather than emitting two parameters that contradict each other.

t= or start=? It Depends Where the Link Lives

Same job, different parameter name, no error when you get it wrong. This is the second most common way an embed silently misbehaves.

What you wantOn a watch link or youtu.beInside an iframe embed
Start at a timet=90 (also accepts 1m30s)start=90 (whole seconds only)
Stop at a timeNo documented parameterend=135, counted from 0:00
Loop the videoNo documented parameterloop=1 AND playlist=VIDEO_ID
AutoplayNo documented parameterautoplay=1 AND mute=1
Hide controlsNot possiblecontrols=0
Keep a playlistlist=PLxxxxxxxxlist=PLxxxxxxxx, or /embed/videoseries?list=
Reduce trackingNot availableSwap the host to youtube-nocookie.com

The practical rule: if a human is going to click it, you want a watch link with t=, and the YouTube Timestamp Link Generator builds those. If a browser is going to render it inside your page, you want an iframe with start=, and that is this tool. Pasting a t= link into an iframe drops the time, and pasting an /embed/ URL into a chat message gives people a bare player with no title, description, or channel, so it is worth keeping the two jobs straight.

Every Parameter, and the Catch That Comes With It

What this generator writes, what it deliberately leaves out, and why. Values come from YouTube's published player parameter reference.

ParameterWhat it doesWe write it?The catch
start=90Begins playback 90 seconds in.YesWhole seconds only. The player seeks to the nearest keyframe, so it can land up to about two seconds early.
end=135Stops playback at 2:15.YesCounted from 0:00 of the video, never from your start value. A 1:30 to 2:15 clip is start=90 and end=135.
autoplay=1Starts the video on page load.YesUseless on its own in modern browsers. Must be paired with mute=1, and YouTube warns that data collection begins on load.
mute=1Starts the player muted.Yes, with autoplayNot on YouTube's documented parameter list, but the player honors it, and it is the only way autoplay actually fires.
loop=1Replays when the video ends.YesDoes nothing on a single video by itself. YouTube requires playlist set to the same video ID alongside it.
playlist=VIDEO_IDQueues videos after the first one.Yes, with loopRepeating the current video ID here is what makes loop=1 work. With other IDs it becomes a real queue.
playsinline=1Plays inside the page on iOS.YesWithout it, iPhones may take over the whole screen when playback starts. Default behaviour is subject to change.
rel=0Limits the end-of-video suggestions.YesSince September 25, 2018 it no longer removes related videos, it restricts them to the same channel.
controls=0Hides the player controls.YesFine for silent background video, hostile for anything a viewer might want to pause or seek.
modestbranding=1Used to reduce YouTube branding.No, deprecatedDeprecated on August 15, 2023 and has no effect. The player now picks its own branding treatment.
origin=yourdomainExtra security check for the player.No, API onlyOnly supported for IFrame API embeds (enablejsapi=1). On a plain copy-paste iframe it adds nothing.

Making the Embed Responsive

YouTube's own share dialog hands you a fixed 560 by 315 iframe. On a phone that is wider than the screen, so the page scrolls sideways and the player gets clipped. The classic fix is the padding-bottom trick: a wrapper with position relative and padding-bottom 56.25% (that is 9 divided by 16, expressed as a percentage), then the iframe positioned absolutely to fill it. Percentage padding is always resolved against the parent element's width, so the wrapper keeps a perfect 16:9 box at any container size, in every browser, with no media queries.

Modern CSS does the same thing in one declaration with the aspect-ratio property, and no wrapper element at all. It is supported across current browsers, so if you do not need to support anything ancient, it is cleaner. This generator emits the wrapper version by default because it is safe absolutely everywhere and survives being pasted into a CMS that scrubs stylesheets, but both are shown below and either is fine.

<!-- 1. Padding-bottom wrapper: works in every browser -->
<div style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;">
  <iframe
    src="https://www.youtube-nocookie.com/embed/aBcD3fGhIjk?start=90"
    style="position:absolute;top:0;left:0;width:100%;height:100%;border:0;"
    allowfullscreen></iframe>
</div>

/* 2. Modern CSS: one line, no wrapper */
.video-embed { width: 100%; aspect-ratio: 16 / 9; border: 0; }

Two smaller notes. Vertical Shorts are 9:16, not 16:9, so if you are embedding one, flip the padding to 177.78% or set aspect-ratio: 9 / 16, otherwise you get a letterboxed video in a wide black box. And if your embed sits well below the fold, adding loading="lazy" to the iframe defers the whole YouTube payload until the viewer scrolls near it, which is one of the cheapest page-speed wins available on a video-heavy page.

What Privacy Mode Actually Changes

Turning privacy mode on swaps one word in the host: www.youtube.com becomes www.youtube-nocookie.com. Everything else about the embed is identical, the same video ID, the same parameters, the same player. What changes is that YouTube holds off on storing personalized tracking information about the visitor until they actually start playing the video. If someone loads your page and never presses play, the privacy-enhanced host is substantially quieter than the standard one.

Be precise about what it is not. It is not cookie free: the moment playback starts, normal playback tracking applies. The browser still contacts Google servers to load the player itself, so an embed on any host is still a third-party request. And it is not a legal conclusion, so if you operate under a consent regime, treat the no-cookie host as one mitigation among several rather than as a reason to skip your consent flow. The genuinely airtight option is not to load the iframe at all until the visitor clicks a poster image, which is a pattern worth building on privacy-sensitive pages.

One related gotcha: turning autoplay on works against this. YouTube's own documentation notes that when autoplay is enabled, playback happens with no user interaction, so playback data collection and sharing begin on page load. Autoplay plus the no-cookie host largely cancels out the benefit you turned the no-cookie host on for.

Which Options to Use Where

The right parameter set depends entirely on what the page is for.

Landing pages and product tours

A muted, looping, controls-free hero video reads as motion design rather than a video player. That combination is exactly loop=1, playlist=ID, autoplay=1, mute=1, controls=0, and it fails silently if you miss the playlist half.

Documentation and help articles

Embed only the 40 seconds that answer the question, using start and end together, so readers are not hunting through a 20-minute walkthrough for the one step they need.

Course platforms and lesson pages

Use the no-cookie host and rel=0 so a lesson page does not end by recommending someone else's course, and so page load stays quiet until a student presses play.

Newsletters and PDFs

Neither one can run an iframe. Those need a link, not embed code, which is where a short link to the video (or to a timestamped moment inside it) does the job instead.

Embeds Plus Flyn: The Half an iframe Cannot Reach

The generator is free forever. Add Flyn for every place the video travels as a link instead of an iframe.

Editable destinations

Re-point a short link anytime. If you re-upload a video, fix every posted link with one edit.

Per-placement analytics

Total clicks free on every link; full country, device, and referrer breakdowns on Pro.

QR codes included

Turn a video link into a QR code for slides and printed materials, free on every link.

A free plan that lasts

25 links a month with total click counts and QR codes. No trial countdown. Custom domains come with Pro.

Frequently Asked Questions

How do I get the embed code for a YouTube video?
Paste the video URL into the generator, tick the options you want, and click Generate embed code. You get a full iframe block wrapped in a responsive container, ready to paste into any HTML page, plus the bare embed URL if your CMS only asks for that. Nothing is sent to a server: the video ID is extracted in your browser and the HTML is assembled there too.
Why does loop=1 not loop my YouTube embed?
Because on a single video, loop=1 is ignored unless you also pass playlist set to the same video ID. YouTube documents this explicitly: to loop one video you need both loop=1 and playlist=VIDEO_ID in the embed URL, which makes the player treat the video as a one-item playlist it can restart. This is the single most common reason a YouTube embed plays once and stops, and this generator writes both parameters for you when you turn Loop forever on.
Why is my start time ignored in an embed?
Almost always because you used t= instead of start=. Watch pages and youtu.be links take t=90, but an iframe embed only reads start=90, and a t= on an embed URL is silently dropped. The values are the same plain seconds, only the parameter name changes, so if you copied a timestamped share link straight into an iframe the time will not survive.
How do I make a YouTube embed responsive?
Wrap the iframe in a div with position relative and padding-bottom 56.25%, which is 9 divided by 16 as a percentage, then absolutely position the iframe to fill it. The padding-bottom trick works in every browser because percentage padding is always resolved against the parent width. Modern CSS can do the same job with aspect-ratio: 16 / 9 on the iframe and no wrapper at all, which this page shows side by side. Our generator emits the wrapper version by default because it is safe everywhere.
Why does autoplay not work on my embed?
Browsers block autoplay with sound. Chrome, Safari, and Firefox all require the video to be muted before they will start it without a click, so autoplay=1 on its own usually results in a paused player. Adding mute=1 alongside autoplay=1 is what makes it actually start, which is why this tool always writes the pair together. Note that YouTube also warns that autoplay means playback data collection begins on page load, before the viewer has done anything.
What does rel=0 actually do now?
Not what most tutorials still claim. Before September 25, 2018, rel=0 hid the related-videos grid at the end of playback. After that change you can no longer disable related videos at all: rel=0 now only restricts the suggestions to other videos from the same channel as the one that just played. It is still worth setting on a marketing page, because it keeps viewers inside your own channel instead of sending them anywhere on YouTube.
Is youtube-nocookie.com really cookie free?
It is privacy-enhanced, not cookie free. Swapping the host to youtube-nocookie.com means YouTube holds off on storing personalized tracking information for the visitor until they actually start playing the video. The moment someone presses play, the usual playback tracking applies, and the request to Google servers happens either way, so the page still loads third-party resources. Treat it as a meaningful reduction in tracking on page load, not as a consent-banner exemption.
How do I stop the embed at a specific time?
Use end= with a whole number of seconds. The important catch is that end is always measured from 0:00 of the video, not from your start time, so a clip running from 1:30 to 2:15 needs start=90 and end=135, not end=45. YouTube also seeks to the nearest keyframe for start, so playback can begin up to roughly two seconds before the second you asked for.
Why does my embed say Video unavailable?
The four usual causes are: the channel owner disabled embedding for that video, the video is age restricted (age-restricted videos cannot play in a third-party embed), the video is blocked in the viewer's country, or the video ID in your iframe is wrong or truncated. Open the embed URL on its own in a fresh tab to tell the difference: if it fails there too, it is a YouTube-side restriction rather than a mistake in your HTML.
Can I hide the YouTube logo with modestbranding?
No, not anymore. YouTube deprecated modestbranding on August 15, 2023, and the parameter now has no effect at all: the player decides its own branding treatment based on signals like player size and whether controls are shown. That is why this generator never writes it. If you want the cleanest possible frame, turning controls off gets you closer than any deprecated parameter will.
Do I need the origin parameter in my embed code?
Not for a plain copy-and-paste iframe. YouTube documents origin as an extra security measure that is only supported for IFrame API embeds, meaning the ones where you also set enablejsapi=1 and drive the player with JavaScript. Adding it to a static iframe does nothing useful and can cause confusion if the value ever stops matching your real domain, so this generator leaves it out.
Is this tool free, and can I track how many people watch?
The generator is completely free, with no sign-up and no usage cap, and your recent embeds are kept only in your own browser's localStorage so you can reuse them. Play counts for an embed go to the channel owner in YouTube Analytics, not to you, and an iframe only works on pages you control. For everywhere else you share the video as a link, wrap it in a Flyn short link: total clicks are free on every link, and country, device, and referrer breakdowns come with Pro.

Ready to embed it and measure it?

Generate embed code for free, then shorten the link version with Flyn to see which newsletter, post, or page actually drives plays. Analytics, QR codes, and editable links included.