YouTube Embed Code Generator
Paste a YouTube link, choose the options, get embed code that fits every screen.
Try before you buy.
- Free preview: your video in YouTube’s standard player (Load preview) and the first lines of a class’s CSS; the code, its address and the player with your options need a pass.
- Locked until you unlock it: download and copy.
- Unlock: Pro pass, ₹179 for 30 days or ₹79 for 1 week, a one-time payment that never renews. Unlock: Pro pass, $5.99 for 30 days or $2.99 for 1 week, a one-time payment that never renews.
Ways to unlock shows how to get the full result.
Printing this result is locked in the free preview.
Video
A video, Short, live stream or playlist link — or the embed code you already have.
Says what the video is. “Get title” asks YouTube for it.
Embed code
For website builders and apps that ask for an embed URL.
Preview
The preview loads the YouTube player (or your click-to-load poster) only when you press Load preview.
Locked in the free preview. Opens the ways to unlock this result.
Locked in the free preview. Batch runs unlock with a pass.
Locked in the free preview. Query results unlock with a pass.
About the YouTube Embed Code Generator
Paste a YouTube link — a video, a Short, a playlist or a video in a playlist — and get embed code that scales to the width of your page and keeps the right shape (16:9 for videos, 9:16 for Shorts). Choose privacy-enhanced mode (youtube-nocookie.com), start and end times, muted autoplay, loop, captions in a language, the player’s language, related videos from your own channel, and whether to show the controls and the full-screen button. The options are YouTube’s documented player parameters (autoplay also adds mute=1, see below), written the way YouTube’s own embed code writes them, with a title for screen readers.
The optional click-to-load version shows a poster and a play button and makes no request to YouTube until someone clicks it — the page loads faster and visitors who never press play are not tracked. A live preview loads the real player only when you ask for it.
Without a pass, the free preview plays your video in YouTube’s standard player (Load preview) and shows the first lines of its CSS when you choose a class; the embed code, the player address, the player with your options, the copy buttons and the .html download come with a Pro pass.
How to use it
- Paste the link from YouTube (Share → Copy link, or the address bar). A start time in the link (
?t=90) is picked up. - Type a title for the player — screen readers announce it — or press Get title to read it from YouTube.
- Choose the options: privacy-enhanced mode is on by default; add a start or end time, autoplay (muted), loop, captions or a player language.
- Choose Responsive (fills the width of its container) or Fixed size, and an inline style or a CSS class for sites with a strict Content-Security-Policy.
- Tick Click-to-load for the lightweight version, then, with a pass or after unlocking this result, copy the code (and the CSS, if you chose a class) into your page.
- Press Load preview to try the player before you publish.
Examples
https://youtu.be/dQw4w9WgXcQ?t=90
<iframe src="https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ?start=90" title="…" width="560" height="315" style="display:block;width:100%;height:auto;aspect-ratio:16/9;min-height:200px;border:0" loading="lazy" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
The width and height attributes are the size before the CSS applies; the style makes it fill the width at 16:9.
Loop · dQw4w9WgXcQ
https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ?loop=1&playlist=dQw4w9WgXcQ
YouTube’s documentation says a single video loops only when the playlist parameter names the same video.
https://www.youtube.com/playlist?list=PLFgquLnL59alCl_2TQvOiD5Vgm1hCaGSI
https://www.youtube-nocookie.com/embed/videoseries?list=PLFgquLnL59alCl_2TQvOiD5Vgm1hCaGSI
Captions on · caption language hi
…/embed/VIDEO_ID?cc_load_policy=1&cc_lang_pref=hi
The captions appear in Hindi when the video has Hindi captions.
Common uses
- Embedding a tutorial, a product video or a talk on a website or blog so it fits phones and wide screens alike.
- Pages with many videos, where click-to-load players keep the page fast.
- Sites with privacy requirements, using privacy-enhanced mode and players that load nothing until clicked.
- Starting a video at the part that matters, or playing just one section with a start and end time.
The options and what they do
From YouTube’s player parameters reference:
- Start / End (
start,end): seconds from the beginning of the video. The end is counted from the beginning too, not from the start time. - Autoplay (
autoplay=1): written withmute=1, because browsers let a video start on its own only without sound (Chrome’s autoplay policy).muteis not in YouTube’s list, but the player starts muted with it. YouTube says autoplayed embeds do not add to the view count (YouTube Help). - Loop (
loop=1): a single video also needsplaylist=with its own ID; a playlist starts again after its last video. - Unticking Show controls (
controls=0) hides the control bar, Full-screen button (fs=0) removes that button, and Keyboard shortcuts (disablekb=1) turns off the player’s shortcuts. - Turn captions on (
cc_load_policy=1) shows them even when the viewer has turned them off; Caption language (cc_lang_pref) and Player language (hl) take codes such ashi,enorpt-BR. - Related videos from the same channel (
rel=0): related videos can no longer be switched off — with this they come from the same channel. - Play inline on iPhone (
playsinline=1) and a White progress bar (color=white).
modestbranding and showinfo are not offered: YouTube’s reference says they no longer have any effect.
Privacy-enhanced mode and click-to-load
Privacy-enhanced mode changes the address of the player to www.youtube-nocookie.com. YouTube says it stops views of the embed from influencing what the viewer is shown on YouTube, and that ads in it are not personalised (YouTube Help: Embed videos & playlists).
The player still loads as soon as the page does. The click-to-load version goes further: it is an <iframe> whose srcdoc holds a small page with a poster and a play button, linked to the player. Nothing is fetched from YouTube until the link is clicked — unless you choose YouTube’s own thumbnail as the poster, which loads that one image from i.ytimg.com. The click then opens the player in the same frame and starts it. Because it uses a small inline style, a site whose Content-Security-Policy forbids inline styles needs the normal code instead.
Rules for embedded players
YouTube’s Required Minimum Functionality for embeds asks for:
- a player of at least 200 × 200 pixels (16:9 players at least 480 × 270 is recommended) — the responsive code keeps a minimum height of 200 px;
- an HTTP Referer, which
referrerpolicy="strict-origin-when-cross-origin"keeps; YouTube Help says players without one show “error 153”; - no overlays in front of any part of the player, and not more than one autoplaying player on a page at a time.
Owners can switch off embedding for a video, and age-restricted videos cannot be watched on most other websites — the player then sends viewers to YouTube.
Limitations
- The code cannot tell whether the owner allows embedding: press Load preview, or Get title (YouTube does not answer for private or deleted videos).
- The live preview may not load on this page when its security settings do not allow YouTube frames; the code works on your site either way.
- Clip links (youtube.com/clip/…) cannot be turned into embed code here; use the video’s link with a start and end time.
- Autoplay with sound is up to the browser; the code always asks for muted autoplay.
- MySmartCoPilot is not affiliated with or endorsed by YouTube.
Privacy
Looks up live data online
Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot. The code is made in your browser. Only if you press Get title or Load preview does the browser contact YouTube (to read the video’s title, or to show the player).
Frequently asked questions
What do I get without a pass?
Without a pass, YouTube Embed Code Generator shows your video in YouTube’s standard player (Load preview) and the first lines of a class’s CSS; the code, its address and the player with your options need a pass. Until you unlock it, the result can’t be downloaded or copied. A Pro, Premium or Ultimate pass, a one-time payment that never renews, unlocks the full result. The pricing page lists the passes and their prices.
How do I make a YouTube embed responsive?
Give the iframe width: 100%, height: auto and aspect-ratio: 16 / 9 (9 / 16 for Shorts), as the Responsive code here does. The old trick of a padding-top wrapper is no longer needed in current browsers.
How do I start a YouTube embed at a certain time?
Add start= with the time in seconds to the player address — 1 minute 30 seconds is start=90. Type 1:30 in Start and the tool converts it; a ?t= in the link you paste is picked up automatically.
Why doesn’t autoplay work with sound?
Browsers block video that starts on its own with sound until the visitor has interacted with the site. Muted autoplay is always allowed in Chrome, so the code adds mute=1; viewers can turn the sound on.
Can I hide related videos at the end?
Not any more. YouTube’s reference says rel=0 now shows related videos from the same channel as the video instead of turning them off.
What is youtube-nocookie.com?
It is the address of YouTube’s privacy-enhanced mode. Views of the embed do not shape the viewer’s YouTube recommendations, and ads in it are not personalised. It is on by default here.
Does the click-to-load version still count views?
It plays the same YouTube player once clicked, so the view is YouTube’s to count as usual. Before the click nothing is loaded from YouTube at all.