Skip to content
Snaplytics Tools

YouTube Embed Code Generator

Paste a video, Short or playlist and build the iframe with every option the player takes — autoplay, loop, start and end times, no-cookie mode, responsive size.

Paste a link above and the player appears here

Nothing loads from YouTube until a link is pasted.

Embed code
<!-- paste a YouTube link to get the iframe -->
Size

The frame fills the column it sits in and keeps its shape at every screen width — the wrapper carries a plain aspect-ratio, no padding trick.

Start and end

Seconds (90) or minutes and seconds (1:30). YouTube starts at the nearest keyframe, so the first frame can land a moment early.

Autoplay

The viewer presses play. Kinder on data, and the only behaviour browsers never fight.

Muted

Starts with sound at the viewer’s own volume.

Loop

Plays once and stops on the end screen.

Player controls

The usual bar: play, scrub, volume, quality, fullscreen.

Related videos at the end

rel=0 keeps the suggestions to the same channel. Since 2018 there is no way to remove them entirely.

Captions on by default

Subtitles follow the viewer’s own YouTube setting.

Languages

Two-letter ISO codes. Captions set which subtitle track to prefer; interface sets the language of the player’s own buttons and tooltips. Blank means the viewer’s own.

Privacy-enhanced mode

youtube-nocookie.com: no cookie is set for tracking until the viewer presses play. The usual choice for a site with a cookie banner.

Fullscreen button

The button is there and the iframe is allowed to go fullscreen.

Play inline on iPhone

iOS opens the video fullscreen when it starts, which is Apple’s default.

Keyboard controls

Space, arrows and the usual shortcuts work in the player.

Annotations

Video annotations show as the creator set them.

Load only when scrolled to

loading="lazy" keeps the player out of the first page load — worth a lot on a page with several videos.

Progress bar colour

The played part of the scrub bar. White suits a dark page.

Frame title

What a screen reader announces for the frame. Naming the actual video beats the default — it is the accessibility bit most embeds skip.

How it works

How to get the embed code for a YouTube video?

  1. Paste the YouTube URL

    A video, a Short, or a playlist — from the address bar or the Share button.

  2. Set the player up

    Autoplay, mute, loop, start and end times, captions, controls, colours, language.

  3. Pick the size

    Responsive to the column it sits in, or fixed pixels like YouTube writes it.

  4. Copy the iframe

    One press, straight into your page, theme, or CMS block.

The preview is the embed — the same src the copied code carries, in a real iframe. So the honest test is right there: press play, scrub, check the start time lands where you meant before the code goes anywhere near your page.

Where it pays off

Where the extra options earn their place?

Start on the part that matters

Link a demo at 4:12 and stop it at 5:30 — no “skip ahead to” in the caption.

A frame that fits every screen

The responsive wrapper keeps 16:9 on a phone and a monitor. 9:16 for Shorts.

No cookie until they press play

Privacy-enhanced mode is the default here — the usual answer to a cookie banner.

Pages with several videos

Lazy loading keeps the players out of the first paint, so the page still feels quick.

Under the hood

What each option writes into the URL?

Every control is one documented IFrame player parameter. Handy if you are reading someone else’s embed, or writing the URL by hand.

ParameterWhat it does
autoplay=1Starts on load — only when the player is also muted.
mute=1Starts silent; the viewer can unmute in the player.
loop=1Repeats. A single video also needs playlist=VIDEO_ID.
start / endSeconds from the beginning to start and stop at.
controls=0Hides the whole control bar.
rel=0End-screen suggestions come from the same channel only.
cc_load_policy=1Turns captions on by default.
cc_lang_prefWhich caption language to prefer, e.g. en.
hlLanguage of the player’s own buttons and tooltips.
fs=0Removes the fullscreen button.
playsinline=1Plays in the page on iPhone instead of fullscreen.
disablekb=1Turns off the player’s keyboard shortcuts.
iv_load_policy=3Hides video annotations.
color=whiteWhite progress bar instead of red.
youtube-nocookie.comPrivacy-enhanced host: no tracking cookie until play.

Questions

Frequently asked questions

Is it free, and do I need an account?

Free, no signup, no watermark, no limit. The code is assembled in your own browser — the link you paste is never sent anywhere.

How do I embed a YouTube video on my website?

Paste the video URL above, set the options you want, press “Copy the code”, and paste the iframe into your page where the video should appear. In WordPress use a Custom HTML block; in Squarespace, Wix or Webflow use the embed or code element. Most builders also accept a bare YouTube URL, but that gives you their defaults, not these options.

Why does autoplay not work?

Browsers only allow autoplay when the video is muted — Chrome, Safari and Firefox all block a video that starts making noise on its own. Turning autoplay on here turns muted on with it. Even then a browser may hold it back until the visitor has interacted with the site.

Can I hide the related videos at the end?

Not completely, and any tool promising otherwise is selling an old parameter. Since 2018 rel=0 no longer removes suggestions — it limits them to the same channel as the video. That is what the related-videos toggle does here.

What about modestbranding and showinfo?

Both are gone. showinfo was removed in 2018 and modestbranding was retired in 2023 — the small YouTube logo in the control bar is now always there. They are left out of the generated code on purpose, so what you paste is only parameters that still do something.

What does privacy-enhanced mode change?

It serves the player from youtube-nocookie.com, which does not store viewing-behaviour cookies on the visitor’s device unless they actually play the video. It does not make the embed request-free — the browser still contacts Google to load the player — but it is what most cookie policies and consent tools expect for a video that sits on the page unplayed.

How do I make the video loop?

Turn loop on. A single video also has to name itself as a one-item playlist for looping to work — that quirk is YouTube’s, and the generated code handles it. Loop starts repeating after the first play-through, so it pairs naturally with autoplay and mute.

Why is my embed the wrong shape on mobile?

That is the fixed width and height from YouTube’s own copy button: 560×315 does not shrink. Use the responsive size here — the wrapper carries an aspect-ratio, so the frame fills whatever column it lands in and keeps its shape at every screen width.