Home › Developer Tools › YouTube Embed Code Generator

YouTube Embed Code Generator

Paste a YouTube link in any format, choose start and end times, autoplay, loop, captions and privacy-enhanced mode, and copy clean, responsive iframe code for your website. The preview only loads YouTube when you click it.

Playback

Use seconds (90), mm:ss (1:30) or h:mm:ss.

Player & size

Live preview

Advertisement

How to use the YouTube Embed Code Generator

  1. Paste the YouTube link (or just the 11-character video ID). Shorts are detected and switched to a 9:16 frame.
  2. Set start and end times if you only want part of the video, for example 1:30 to 2:45.
  3. Choose playback options such as autoplay, loop, captions or hidden controls.
  4. Pick a size: Responsive fills the width of its container at the chosen aspect ratio; Fixed size uses exact pixels.
  5. Press Copy Code and paste it into your HTML, WordPress Custom HTML block or page builder. Click Load Preview to check it first.

YouTube links this tool understands

Link formatExample
Watch pagehttps://www.youtube.com/watch?v=VIDEO_ID&t=90s
Short linkhttps://youtu.be/VIDEO_ID?t=1m30s
Shortshttps://www.youtube.com/shorts/VIDEO_ID
Livehttps://www.youtube.com/live/VIDEO_ID
Existing embedhttps://www.youtube.com/embed/VIDEO_ID?start=30
Playlisthttps://www.youtube.com/playlist?list=PL…
Mobile / Musicm.youtube.com, music.youtube.com
Bare ID11 characters of letters, digits, - and _

YouTube embed parameters reference

ParameterValueEffect
startsecondsBegin playback at this second (1:30 = 90).
endsecondsStop playback at this second.
autoplay1Start playing automatically (needs mute=1 in most browsers).
mute1Start muted.
loop + playlist1 + video IDRepeat the video; a single video must be listed as its own playlist.
controls0Hide the player controls.
cc_load_policy1Show captions by default.
cc_lang_preflanguage codePreferred caption language, e.g. en or es.
rel0Related videos at the end come from the same channel.
playsinline1Play inside the page on iPhone instead of fullscreen.
fs0Hide the fullscreen button.

Responsive embed: how the padding trick works

An iframe has no natural aspect ratio, so the responsive code wraps it in a div with height:0 and a bottom padding equal to height ÷ width × 100. Percentage padding is measured against the container's width, so the box always keeps the right shape, and the iframe is stretched to fill it with absolute positioning.

Aspect ratioPadding-bottomTypical use
16:99 ÷ 16 = 56.25%Standard YouTube videos
9:1616 ÷ 9 = 177.7778%YouTube Shorts
4:33 ÷ 4 = 75%Older recordings, presentations
1:1100%Square social clips

Frequently asked questions

How do I embed a YouTube video on my website?

Paste the video link above, copy the generated code and paste it into your page's HTML where the video should appear. In WordPress use a Custom HTML block; in most site builders use an Embed or HTML element.

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

Enter the time in the Start at field, for example 1:30. The tool adds start=90 to the embed URL. If your link already contains ?t=90 or ?t=1m30s, the start time is filled in automatically. Use End at to stop playback at a given second.

Why doesn't my embedded YouTube video autoplay?

Browsers only allow autoplay when the video is muted, so the tool switches on Start muted when you tick Autoplay. Data-saver modes and some mobile browsers may still block autoplay entirely.

How do I loop a YouTube embed?

Tick Loop. For a single video YouTube also requires a playlist parameter containing the same video ID, which the generator adds for you (loop=1&playlist=VIDEO_ID).

What is privacy-enhanced mode?

Embeds from youtube-nocookie.com do not store YouTube cookies or personalise ads for visitors until they play the video. It is the recommended option for GDPR-conscious sites and works the same for viewers.

How do I make a YouTube embed responsive?

Use the Responsive option. The iframe is placed inside a wrapper with a percentage padding (56.25% for 16:9) so it scales with the width of the page while keeping its shape. Set a max width if it should not grow beyond a certain size.

Can I embed YouTube Shorts?

Yes. Paste the youtube.com/shorts/ link; the generator converts it to a normal embed URL and selects a vertical 9:16 frame.

Related tools