YouTube Embed Code Generator

Build an iframe with a start time, looping, hidden controls or privacy-enhanced mode, then preview it before you copy.


What this tool does

YouTube’s own Share menu gives you a basic embed snippet with no options. This page builds the same kind of snippet but lets you set the behaviour first — where the video starts, whether it loops, whether the player chrome is visible — and shows you a live preview so you can check the result before it goes anywhere near your site.

The options explained

Privacy-enhanced mode

Switches the embed to the youtube-nocookie.com domain. YouTube then holds off on setting tracking cookies until the visitor actually presses play. If your site serves visitors in the EU or UK, this meaningfully reduces what you need to disclose in a cookie banner, and it costs you nothing — the player looks and behaves the same. It is on by default here for that reason.

Autoplay and Start muted

Chrome, Safari and Firefox all block autoplay with sound. If you tick Autoplay on its own, most visitors would simply see a paused video — so the tool adds mute=1 for you automatically and tells you it has done so. That is what makes autoplay actually work.

Worth saying plainly: autoplay annoys people and hurts your page speed scores. Use it sparingly.

Loop

A single video cannot loop on its own — YouTube requires a playlist parameter for looping to work, so the tool quietly adds the video to a one-item playlist behind the scenes. This is why the generated code contains the video ID twice.

Hide controls

Removes the play bar, volume and settings. Reasonable for a short background clip, poor for anything a visitor might want to pause or scrub through.

Start at

Accepts 90, 1:30, or 1:02:30. The video still loads from the beginning, it just begins playing at that point.

Where to paste the code

In WordPress, add a Custom HTML block and paste it there. In Elementor, use the HTML widget. In a plain HTML site, paste it wherever you want the player to appear. Do not paste it into a visual editor’s rich text area — most of them will strip the iframe.

Making it responsive

The generated iframe has fixed dimensions of 560 by 315, which is what YouTube supplies. On narrow screens that will overflow. Adding one line of CSS to your stylesheet fixes it everywhere:

iframe[src*="youtube"] { width: 100%; aspect-ratio: 16 / 9; height: auto; }

Frequently asked questions

Is embedding a video allowed?

Yes. YouTube provides embedding as a standard feature and views on an embedded player still count toward the creator’s statistics. Uploaders can switch embedding off for their videos, in which case the player will show an error instead — that is their choice, not a fault in the code.

Does the preview here count as a view?

Only if you press play, the same as anywhere else.

Will this slow my page down?

A YouTube iframe pulls in a substantial amount of script. If you are embedding several videos on one page, consider a lazy-loading approach where the player only loads after a click.

Can I embed a Shorts video?

Yes. Paste the Shorts link and it will be converted to a standard embed. The player will be widescreen rather than vertical.

What if I want the video file instead of an embed?

Embedding streams the video from YouTube and keeps the creator’s view count intact, which is the right choice for a website. If you genuinely need the file itself, our video downloader saves it as MP4 or MP3 — but do not re-upload someone else’s video to your own site in place of an embed.

Other tools here

The thumbnail downloader pulls a video’s cover image at full size, the video ID extractor handles bulk link lists, and the playlist duration calculator tells you how long a playlist takes to watch. All eight are on the tools page.