YouTube Embed Code Generator
<div style="position:relative;border-radius:24px;overflow:hidden;width:100%;aspect-ratio:16 / 9;"> <iframe style="position:absolute;inset:0;width:100%;height:100%;border:0;" src="https://www.youtube.com/embed/aqz-KE-bpKQ?rel=0&playsinline=1" 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> <p style="margin:4px auto 0;text-align:center;font:11px/1.4 -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;color:#a3a7b0;">Created with <a href="https://elfsight.com/tools/youtube-embed-code-generator/" target="_blank" rel="noopener" style="color:inherit;text-decoration:none;">Elfsight</a></p>
- Click Copy code above to copy it.
- Open the page’s HTML file or template.
- Paste the code inside
<body>, where the content should appear. - Save and upload the page, then open it in a browser to check.
Need more than one video?
Show the whole channel as an interactive gallery that updates itself.
See Video Gallery for HTML →Want the whole channel, not one video?
Auto-updates when you publish new videos
Carousel, grid, masonry or player with playlist
YouTube, Vimeo, TikTok, Instagram, Twitch and any video link
No coding — works on any website
YouTube’s Share → Embed vs. this generator
start= in seconds to the codeend= in seconds to the codeautoplay=1 to the codeloop=1 and playlist= with the same video IDcc_load_policy=1 to the codeyoutube-nocookie.comStart time
YouTube’s Share → Embed
start= in seconds to the codeThis generator
End time
YouTube’s Share → Embed
end= in seconds to the codeThis generator
Autoplay
YouTube’s Share → Embed
autoplay=1 to the codeThis generator
Loop one video
YouTube’s Share → Embed
loop=1 and playlist= with the same video IDThis generator
Captions on by default
YouTube’s Share → Embed
cc_load_policy=1 to the codeThis generator
Privacy-enhanced mode
YouTube’s Share → Embed
youtube-nocookie.comThis generator
Size
YouTube’s Share → Embed
This generator
How to use the YouTube Embed Code generator
Paste a link
Copy any youtube.com, youtu.be, Shorts, live or playlist URL and paste it above.
Choose options
Turn on autoplay, loop, captions, a start time or privacy-enhanced mode. The code updates live.
Copy and paste
Click Copy code and paste it into your website builder’s HTML or embed block.
YouTube embed parameters
autoplayautoplay=1muteautoplay=1&mute=1startstart=90endstart).start=30&end=90loopplaylist set to the same video ID.loop=1&playlist=VIDEO_IDplaylistplaylist=ID2,ID3list + listTypePL) or a channel’s uploads (listType=user_uploads). The search list type stopped working on November 15, 2020.listType=playlist&list=PL…controls0 hides the player controls. Default 1.controls=0fs0 hides the full-screen button. Default 1.fs=0disablekb1 turns off keyboard shortcuts in the player.disablekb=1cc_load_policy1 shows captions by default, even if the viewer has turned them off.cc_load_policy=1cc_lang_prefcc_load_policy=1, captions show in this language from the start.cc_lang_pref=fr&cc_load_policy=1hlhl=decolorred (default) or white.color=whiteiv_load_policy3 hides video annotations; 1 (default) shows them.iv_load_policy=3playsinline1 plays the video inside the page on iPhone and iPad instead of switching to full screen.playsinline=1rel0 shows related videos from the same channel.rel=0enablejsapi1 lets scripts on your page control the player through the IFrame Player API. Set origin too.enablejsapi=1originorigin=https://example.comwidget_referrerwidget_referrer=https://example.com/pagemodestbrandingshowinfoyoutube-nocookie.comhttps://www.youtube-nocookie.com/embed/VIDEO_IDautoplay
What it does
Example
autoplay=1mute
What it does
Example
autoplay=1&mute=1start
What it does
Example
start=90end
What it does
start).Example
start=30&end=90loop
What it does
playlist set to the same video ID.Example
loop=1&playlist=VIDEO_IDplaylist
What it does
Example
playlist=ID2,ID3list + listType
What it does
PL) or a channel’s uploads (listType=user_uploads). The search list type stopped working on November 15, 2020.Example
listType=playlist&list=PL…controls
What it does
0 hides the player controls. Default 1.Example
controls=0fs
What it does
0 hides the full-screen button. Default 1.Example
fs=0disablekb
What it does
1 turns off keyboard shortcuts in the player.Example
disablekb=1cc_load_policy
What it does
1 shows captions by default, even if the viewer has turned them off.Example
cc_load_policy=1cc_lang_pref
What it does
cc_load_policy=1, captions show in this language from the start.Example
cc_lang_pref=fr&cc_load_policy=1hl
What it does
Example
hl=decolor
What it does
red (default) or white.Example
color=whiteiv_load_policy
What it does
3 hides video annotations; 1 (default) shows them.Example
iv_load_policy=3playsinline
What it does
1 plays the video inside the page on iPhone and iPad instead of switching to full screen.Example
playsinline=1rel
What it does
0 shows related videos from the same channel.Example
rel=0enablejsapi
What it does
1 lets scripts on your page control the player through the IFrame Player API. Set origin too.Example
enablejsapi=1origin
What it does
Example
origin=https://example.comwidget_referrer
What it does
Example
widget_referrer=https://example.com/pagemodestbranding
What it does
Example
showinfo
What it does
Example
youtube-nocookie.com
What it does
Example
https://www.youtube-nocookie.com/embed/VIDEO_IDEmbedded YouTube video not working? Common fixes
The player says the video can’t be played on other websites
The owner has turned off Allow embedding. Only the owner can change this, in YouTube Studio under Details → Show more. If it’s not your video, link to it on YouTube instead.
Error 153
YouTube requires embedding pages to send an HTTP Referer, and blocks playback without one. Remove referrerpolicy="no-referrer" from the iframe and check your site doesn’t send a no-referrer policy. YouTube recommends strict-origin-when-cross-origin, the default in many browsers.
Autoplay doesn’t start
Browsers block autoplay with sound. Start the video muted, keep autoplay in the iframe’s allow attribute, and remember that YouTube doesn’t count autoplayed embeds as views.
Loop plays the video only once
For a single video, YouTube needs loop=1 together with playlist= set to the same video ID.
Related videos still show at the end with rel=0
Since September 25, 2018, related videos can’t be turned off. rel=0 now limits them to videos from the same channel.
An age-restricted video won’t play
YouTube says age-restricted videos can’t be watched on most third-party websites. Link to the video on YouTube instead.
The player looks cramped or the controls are cut off
YouTube requires an embedded player of at least 200 × 200 px and recommends at least 480 × 270 px for 16:9 video. Give the player more room or use the responsive option.
Why autoplay doesn’t work
Browsers block videos that start playing with sound on their own. Muted playback is generally allowed, so an embed that should start by itself has to start muted: autoplay=1&mute=1. Visitors can turn the sound on with the player controls.
The iframe must allow it. A YouTube player is an iframe from another site, so autoplay only works when its
allowattribute includesautoplay.iPhone and iPad. Add
playsinline=1so the video plays inside the page instead of opening full screen.Views. YouTube says autoplayed embeds don’t increase the video’s view count.
Privacy. With autoplay on, the player starts collecting and sharing playback data as soon as the page loads, without any action from the visitor.
Details: Chrome autoplay policy, MDN autoplay guide, YouTube player parameters.
Embed code vs. Elfsight Video Gallery
Videos per embed
Embed code
Video Gallery
Stays up to date
Embed code
Video Gallery
Mix sources
Embed code
Video Gallery
Layouts
Embed code
Video Gallery
Responsive design
Embed code
Video Gallery
Coding
Embed code
Video Gallery
Price
Embed code
Video Gallery