YouTube Embed Code Generator

Build a responsive YouTube iframe with start and end times, muted autoplay, loop, captions, and the privacy player.

Build the exact iframe snippet for any YouTube video, Short, or playlist: responsive sizing, start and end times, muted autoplay, loop, captions, lazy loading, and the privacy-enhanced player, with a live preview.

How it works

Paste any YouTube URL: a normal watch link, a short youtu.be link, a Shorts link, a live-stream link, or a playlist. The tool reads the video and playlist ids in your browser. It fetches the video's title through YouTube's public oEmbed endpoint, which also confirms the video exists and can be embedded. Then it builds the iframe snippet from your options. A playlist URL produces a playlist player. A watch link that carries a playlist keeps the playlist context.

The defaults are what most sites should ship: the privacy-enhanced youtube-nocookie.com domain, responsive aspect-ratio sizing (9:16 for Shorts, 16:9 otherwise), lazy loading, and a title attribute for accessibility. Options YouTube has retired, such as modestbranding, are left out on purpose. The FAQ explains what still works. The preview below the code is the real player, shown without autoplay.

Everything happens in your browser and nothing is stored. For a timestamped link instead of an embed, use the YouTube Timestamp Link Generator. To check a video's public data first, the YouTube Video Data Viewer shows whether embedding is allowed at all.

What the options mean

Privacy-enhanced player
Serves the embed from youtube-nocookie.com, so no advertising cookies are set for visitors who never click play.
Start at / End at
Clip the embed to one section. Accepts seconds (90) or clock times (1:30, 1:02:03).
Autoplay (muted)
Starts playback on its own with the sound off, the only autoplay browsers allow.
Loop
Restarts the video when it ends. For a single video the snippet uses YouTube's loop plus playlist trick.
Hide player controls
Removes the play bar and buttons (controls=0), for background-video effects.
Captions on
Turns closed captions on where available (cc_load_policy=1).
Only suggest videos from this channel
rel=0: end-screen suggestions come from the same channel instead of all of YouTube.
Sizing
Responsive aspect-ratio CSS (default), the older padding-bottom wrapper, or a fixed pixel size.
Lazy-load
loading="lazy": the browser fetches the player only when it nears the viewport.

Frequently asked questions

How do I embed a YouTube video on my website?

Paste the video URL above, pick your options, and copy the iframe snippet into your page's HTML where the player should appear. It is the same iframe that YouTube's own Share and Embed button produces. This tool adds the options that button does not offer: start and end times, muted autoplay, loop, hidden controls, captions, lazy loading, responsive sizing, and the privacy-enhanced player domain.

How do I make a YouTube embed responsive?

Give the iframe a width of 100 percent and a fixed aspect ratio instead of fixed pixels. The default snippet here uses the modern aspect-ratio: 16/9 CSS, which every current browser supports. The "padding wrapper" option produces the older padding-bottom: 56.25% container, which also works in very old browsers. A Shorts URL switches the ratio to 9:16 on its own.

Why will my embedded video not autoplay?

Browsers block autoplay with sound. An embed can only start on its own when it is muted, so the Autoplay option here always writes autoplay=1&mute=1 together. Even muted, some browsers and battery-saver modes delay playback until the iframe is visible. The preview on this page strips autoplay so the page itself stays quiet.

What is youtube-nocookie.com?

It is the privacy-enhanced player domain. Serving the embed from www.youtube-nocookie.com tells YouTube not to store advertising cookies or personalise ads for visitors who see the player without clicking play. Many sites use it to reduce what their cookie banner has to cover. Playback is identical. This generator defaults to it. Untick the option for the standard www.youtube.com player.

How do I start an embedded video at a specific time?

Fill in the "Start at" field with a time such as 90 or 1:30. The snippet gets a start=90 parameter counted in seconds. "End at" works the same way with end=, so you can clip the embed to one section of a long video. For a plain link with a timestamp rather than an embed, use the YouTube Timestamp Link Generator.

How do I loop an embedded YouTube video?

Tick Loop. For a single video, YouTube needs loop=1 combined with playlist=<the same video id>, a documented trick the generator writes for you. A playlist embed loops with loop=1 alone. Looping goes well with muted autoplay and hidden controls for a background-video effect.

Can I remove the YouTube logo or related videos from an embed?

Not fully. YouTube retired the modestbranding parameter that once hid the logo in 2023, and now ignores it, so this generator does not offer it. Since 2018, rel=0 no longer removes related videos either. It only limits the end-screen suggestions to more videos from the same channel, which is what the "Only suggest videos from this channel" option writes. Hiding the controls with controls=0 still works.

Does embedding a video slow my page down?

A player that loads right away pulls several hundred kilobytes of script before anyone clicks play. The Lazy-load option, on by default, adds loading="lazy". The browser then fetches the player only when the iframe nears the viewport, which usually removes the cost from the initial page load. For a page with many videos, the fastest pattern is a clickable thumbnail that swaps in the iframe on click. Grab the thumbnail with the YouTube Thumbnail Downloader.