Generate responsive YouTube embed code without the guesswork
YouTube’s own Share → Embed button gives you a fixed 560 × 315 iframe with no options. The YouTube embed code generator builds the full iframe for you: paste any link — including Shorts, live streams, youtu.be short links and playlists — and choose a start and end time, autoplay, mute, loop, captions, player controls, lazy loading and privacy-enhanced youtube-nocookie.com mode. The code updates as you tick boxes, and a preview loads the real player only when you ask for it.
The output is responsive by default, using the modern CSS aspect-ratio property or the classic padding-top wrapper, so the video fills a blog column on desktop and shrinks cleanly on phones. It also includes the referrerpolicy attribute that prevents the common “Error 153: Video player configuration error”.
How to use the YouTube Embed Code Generator
- Paste the video link into YouTube video or playlist link. If it contains a timestamp (t=1m30s), the start time is filled in automatically.
- Set a Start at and optional End at time using 1:30, 90 or 1h2m3s formats.
- Pick a Size: responsive (recommended) or a fixed width such as 640 × 360, and the Aspect ratio (9:16 for Shorts).
- Tick the options you need — autoplay, loop, captions, privacy mode, lazy loading — and give the iframe a descriptive Title.
- Press Preview to check it, then Copy HTML and paste the code into your page, WordPress HTML block, Notion, Webflow or Shopify.
YouTube Embed Code Generator features
Every link format
Handles watch?v=, youtu.be, Shorts, live, embed and playlist URLs, plus timestamps and tracking parameters.
Responsive by default
Choose aspect-ratio CSS (one line, all modern browsers) or the padding-top wrapper for older site builders.
Correct autoplay
Autoplay only works muted in Chrome, Safari and Firefox, so ticking it adds mute=1 and the autoplay permission automatically.
Working loop
YouTube ignores loop=1 on its own; the generator adds the required playlist parameter so the video really repeats.
Privacy-enhanced mode
youtube-nocookie.com stops YouTube storing cookies until the visitor presses play — useful for GDPR-conscious sites.
Error-153 safe
Includes referrerpolicy="strict-origin-when-cross-origin" and a title attribute for accessibility and SEO.
YouTube embed parameters explained
| Parameter | What it does | Notes |
|---|---|---|
| start=90 / end=120 | Begins and stops playback at those seconds | end only works with start or on its own in the embed URL |
| autoplay=1 | Starts playing on load | Browsers block unmuted autoplay; mute=1 and allow="autoplay" are required |
| mute=1 | Starts with the sound off | Visitors can unmute with the player controls |
| loop=1&playlist=ID | Repeats the video | The playlist parameter must contain the same video ID |
| controls=0 | Hides the player controls | Visitors can still pause by clicking the video |
| cc_load_policy=1 | Shows captions by default | Only if the video has captions |
| rel=0 | End-screen suggestions come from the same channel | YouTube no longer allows hiding related videos entirely |
| fs=0 | Removes the fullscreen button | Also drop the allowfullscreen attribute |
Responsive embeds: aspect-ratio vs. padding trick
The one-line method sets width:100% and aspect-ratio:16/9 on the iframe itself. It is supported by every browser released since 2021 and is the cleanest choice for new sites. The older approach wraps the iframe in a <div> with padding-top:56.25% (9 ÷ 16) and positions the iframe absolutely inside it; it works everywhere, including very old browsers and some page builders that strip modern CSS. For Shorts choose 9:16 (padding 177.78%), and use the Aspect Ratio Calculator for anything unusual.
Lazy loading (loading="lazy") tells the browser not to fetch the player until the visitor scrolls near it, which can cut a page’s initial download by 500 KB or more per video.
Troubleshooting embedded videos
- “Video unavailable” or “Playback on other websites has been disabled”: the owner turned embedding off in YouTube Studio. Only they can change it; link to the video instead.
- Error 153 – Video player configuration error: the page sends no referrer. Keep the
referrerpolicyattribute this tool adds, or set a referrer policy other than no-referrer on your site. - Autoplay does nothing: make sure mute=1 is present and allow="autoplay" is in the iframe; some mobile browsers still block autoplay on cellular data.
- Looping stops after one play: the playlist parameter is missing — tick Loop here and copy the code again.
- Need a clickable link with a start time instead of an embed? Use the YouTube Timestamp Link tool, or grab the cover image with the YouTube Thumbnail Downloader.
YouTube Embed Code Generator FAQ
How do I embed a YouTube video in HTML?
Paste the video link above, choose your options and copy the generated iframe code into your page where you want the video to appear. No JavaScript is needed.
How do I make a YouTube embed responsive?
Choose one of the Responsive sizes. The code either sets aspect-ratio on the iframe or wraps it in a padding-top container, so the player scales to the width of its column.
How do I start an embedded YouTube video at a specific time?
Enter the time in “Start at” (for example 1:30) or paste a link that already contains t=90s. The generator adds start=90 to the embed URL.
Why doesn’t autoplay work on my embedded video?
Modern browsers only allow autoplay when the video is muted and the iframe has allow="autoplay". Ticking Autoplay here adds both. Low-power mode and data-saver settings on phones can still block it.
What is youtube-nocookie.com?
It is YouTube’s privacy-enhanced embed domain. The player does not set tracking cookies until the visitor interacts with it, which helps with GDPR and cookie-banner requirements.
Can I embed a YouTube Shorts video?
Yes. Paste the youtube.com/shorts/… link; the generator switches to a 9:16 aspect ratio automatically and uses the normal embed player.
Can I embed a whole playlist?
Yes. Paste a playlist link (containing list=) and the code uses the videoseries embed, which plays the playlist in order.