YouTube Embed Code Generator

Paste any YouTube link and get a free, responsive embed code in seconds. Set autoplay, loop, start time, captions and privacy mode, then copy the iframe into any website. No sign-up needed.
A video, Short or live stream link, e.g. https://www.youtube.com/watch?v=aqz-KE-bpKQ
Want the whole channel as a gallery that updates itself?
Corner radius

Embed the video

<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>

  1. Click Copy code above to copy it.
  2. Open the page’s HTML file or template.
  3. Paste the code inside <body>, where the content should appear.
  4. 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 →

Before you go

Need more than one video? Show the whole channel as an interactive gallery that updates itself.

Embed a YouTube channel →
Or share this free tool:
Elfsight Video Gallery

Want the whole channel, not one video?

Video Gallery turns your YouTube channel or playlist into a gallery that updates itself — every new upload appears on your site automatically.
  • 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

YouTube’s embed dialog gives you a basic iframe. YouTube’s own help explains most other settings as edits you make to that code by hand.
Feature
YouTube’s Share → Embed
This generator
Start time
Add start= in seconds to the code
Type mm:ss, converted to seconds
End time
Add end= in seconds to the code
Type mm:ss, converted to seconds
Autoplay
Add autoplay=1 to the code
One switch; the video starts muted so browsers allow it
Loop one video
Add loop=1 and playlist= with the same video ID
One switch; both parameters are added
Captions on by default
Add cc_load_policy=1 to the code
One switch
Privacy-enhanced mode
Change the domain to youtube-nocookie.com
One switch
Size
Fixed width and height in pixels
Responsive 16:9 box that fits the page width

Start time

YouTube’s Share → Embed

Add start= in seconds to the code

This generator

Type mm:ss, converted to seconds

End time

YouTube’s Share → Embed

Add end= in seconds to the code

This generator

Type mm:ss, converted to seconds

Autoplay

YouTube’s Share → Embed

Add autoplay=1 to the code

This generator

One switch; the video starts muted so browsers allow it

Loop one video

YouTube’s Share → Embed

Add loop=1 and playlist= with the same video ID

This generator

One switch; both parameters are added

Captions on by default

YouTube’s Share → Embed

Add cc_load_policy=1 to the code

This generator

One switch

Privacy-enhanced mode

YouTube’s Share → Embed

Change the domain to youtube-nocookie.com

This generator

One switch

Size

YouTube’s Share → Embed

Fixed width and height in pixels

This generator

Responsive 16:9 box that fits the page width

How to use the YouTube Embed Code generator

  1. Paste a link

    Copy any youtube.com, youtu.be, Shorts, live or playlist URL and paste it above.

  2. Choose options

    Turn on autoplay, loop, captions, a start time or privacy-enhanced mode. The code updates live.

  3. Copy and paste

    Click Copy code and paste it into your website builder’s HTML or embed block.

YouTube embed parameters

Parameter
What it does
Example
autoplay
Starts the video when the player loads. Browsers usually block this unless the video is muted. Autoplayed embeds don’t count as YouTube views.
autoplay=1
mute
Starts the player muted, which lets autoplay work. Not listed in Google’s parameter documentation.
autoplay=1&mute=1
start
Starts playback this many seconds into the video. The player jumps to the nearest keyframe, so it may start up to about two seconds early.
start=90
end
Stops playback at this second, counted from the start of the video (not from start).
start=30&end=90
loop
Replays the video. For a single video it only works with playlist set to the same video ID.
loop=1&playlist=VIDEO_ID
playlist
Comma-separated video IDs to play after the first video.
playlist=ID2,ID3
list + listType
Loads a playlist (ID starts with PL) or a channel’s uploads (listType=user_uploads). The search list type stopped working on November 15, 2020.
listType=playlist&list=PL…
controls
0 hides the player controls. Default 1.
controls=0
fs
0 hides the full-screen button. Default 1.
fs=0
disablekb
1 turns off keyboard shortcuts in the player.
disablekb=1
cc_load_policy
1 shows captions by default, even if the viewer has turned them off.
cc_load_policy=1
cc_lang_pref
Caption language as an ISO 639-1 code or BCP 47 tag. With cc_load_policy=1, captions show in this language from the start.
cc_lang_pref=fr&cc_load_policy=1
hl
Language of the player interface (tooltips) and the default caption track.
hl=de
color
Color of the progress bar: red (default) or white.
color=white
iv_load_policy
3 hides video annotations; 1 (default) shows them.
iv_load_policy=3
playsinline
1 plays the video inside the page on iPhone and iPad instead of switching to full screen.
playsinline=1
rel
Changed on September 25, 2018: related videos can no longer be turned off. 0 shows related videos from the same channel.
rel=0
enablejsapi
1 lets scripts on your page control the player through the IFrame Player API. Set origin too.
enablejsapi=1
origin
Your site’s domain, an extra security measure when the IFrame Player API is used.
origin=https://example.com
widget_referrer
The page URL where the player is embedded, used by YouTube Analytics to credit the traffic.
widget_referrer=https://example.com/page
modestbranding
Deprecated on August 15, 2023; has no effect. YouTube now picks the branding from the player size and other settings.
—
showinfo
Deprecated in 2018 and ignored since September 25, 2018. The video title can’t be hidden with a parameter.
—
youtube-nocookie.com
Not a parameter but a domain: privacy-enhanced mode. Views don’t shape the viewer’s YouTube experience, and ads are non-personalized.
https://www.youtube-nocookie.com/embed/VIDEO_ID

autoplay

What it does

Starts the video when the player loads. Browsers usually block this unless the video is muted. Autoplayed embeds don’t count as YouTube views.

Example

autoplay=1

mute

What it does

Starts the player muted, which lets autoplay work. Not listed in Google’s parameter documentation.

Example

autoplay=1&mute=1

start

What it does

Starts playback this many seconds into the video. The player jumps to the nearest keyframe, so it may start up to about two seconds early.

Example

start=90

end

What it does

Stops playback at this second, counted from the start of the video (not from start).

Example

start=30&end=90

loop

What it does

Replays the video. For a single video it only works with playlist set to the same video ID.

Example

loop=1&playlist=VIDEO_ID

playlist

What it does

Comma-separated video IDs to play after the first video.

Example

playlist=ID2,ID3

list + listType

What it does

Loads a playlist (ID starts with 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=0

fs

What it does

0 hides the full-screen button. Default 1.

Example

fs=0

disablekb

What it does

1 turns off keyboard shortcuts in the player.

Example

disablekb=1

cc_load_policy

What it does

1 shows captions by default, even if the viewer has turned them off.

Example

cc_load_policy=1

cc_lang_pref

What it does

Caption language as an ISO 639-1 code or BCP 47 tag. With cc_load_policy=1, captions show in this language from the start.

Example

cc_lang_pref=fr&cc_load_policy=1

hl

What it does

Language of the player interface (tooltips) and the default caption track.

Example

hl=de

color

What it does

Color of the progress bar: red (default) or white.

Example

color=white

iv_load_policy

What it does

3 hides video annotations; 1 (default) shows them.

Example

iv_load_policy=3

playsinline

What it does

1 plays the video inside the page on iPhone and iPad instead of switching to full screen.

Example

playsinline=1

rel

What it does

Changed on September 25, 2018: related videos can no longer be turned off. 0 shows related videos from the same channel.

Example

rel=0

enablejsapi

What it does

1 lets scripts on your page control the player through the IFrame Player API. Set origin too.

Example

enablejsapi=1

origin

What it does

Your site’s domain, an extra security measure when the IFrame Player API is used.

Example

origin=https://example.com

widget_referrer

What it does

The page URL where the player is embedded, used by YouTube Analytics to credit the traffic.

Example

widget_referrer=https://example.com/page

modestbranding

What it does

Deprecated on August 15, 2023; has no effect. YouTube now picks the branding from the player size and other settings.

Example

—

showinfo

What it does

Deprecated in 2018 and ignored since September 25, 2018. The video title can’t be hidden with a parameter.

Example

—

youtube-nocookie.com

What it does

Not a parameter but a domain: privacy-enhanced mode. Views don’t shape the viewer’s YouTube experience, and ads are non-personalized.

Example

https://www.youtube-nocookie.com/embed/VIDEO_ID

Source: YouTube embedded players and player parameters

Embedded 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 allow attribute includes autoplay.

  • iPhone and iPad. Add playsinline=1 so 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

Embed code
Video Gallery
Videos per embed
One video (or one playlist)
Unlimited videos in one widget
Stays up to date
Edit the code for every new video
New YouTube videos appear automatically
Mix sources
One platform per snippet
YouTube, Vimeo, TikTok, Instagram, Twitch and any video link
Layouts
Single player
Player with Gallery, Carousel, Grid, Masonry, Playlist
Responsive design
Needs a CSS wrapper
Built in
Coding
Copy and paste code for each video
No code — edit visually in the editor
Price
Free
Free plan, no credit card needed

Videos per embed

Embed code

One video (or one playlist)

Video Gallery

Unlimited videos in one widget

Stays up to date

Embed code

Edit the code for every new video

Video Gallery

New YouTube videos appear automatically

Mix sources

Embed code

One platform per snippet

Video Gallery

YouTube, Vimeo, TikTok, Instagram, Twitch and any video link

Layouts

Embed code

Single player

Video Gallery

Player with Gallery, Carousel, Grid, Masonry, Playlist

Responsive design

Embed code

Needs a CSS wrapper

Video Gallery

Built in

Coding

Embed code

Copy and paste code for each video

Video Gallery

No code — edit visually in the editor

Price

Embed code

Free

Video Gallery

Free plan, no credit card needed

Frequently asked questions

Official documentation

Chrome autoplay policy

Why autoplay needs the video to be muteddeveloper.chrome.com/blog/autoplayChrome autoplay policy

More free tools

Related guides

How to embed YouTube videos on website

Click Share → Embed on YouTube and paste the iframe, or generate a responsive code with options. To show a whole channel or playlist, use a YouTube feed widget.How to embed YouTube videos on website

How to autoplay embedded YouTube videos

Add ?autoplay=1&mute=1 to the YouTube embed URL. Browsers block autoplay with sound, so the mute parameter is what makes it work.How to autoplay embedded YouTube videos

How to embed a video on a website

Upload the video to YouTube or Vimeo and paste its embed code, use the HTML5 video tag for files you host yourself, or use a video gallery widget when you need several videos. Here’s how each method works and when to use it.How to embed a video on a website