Skip to content

YouTube Embed Code Generator

Social Media Tools ·
·

Turn any YouTube link into responsive iframe embed code with autoplay, loop, start time, and privacy options

The short version

Paste a YouTube link, get clean iframe HTML back. That’s the whole pitch. The generator accepts watch URLs, youtu.be short links, Shorts, embed, and live URLs, plus a bare 11-character video ID, and it rebuilds the embed code live as you flip options. A working preview sits next to the code so you can see exactly what your visitors will get before you copy anything.

The default output uses a responsive wrapper: a container with 56.25% bottom padding that locks the player to a 16:9 ratio at any width. Fixed 560x315 iframes overflow on phones. This doesn’t. If you genuinely need exact pixels, switch the wrapper off and pick from four presets up to 1280x720.

Under the hood

Every option maps to a real YouTube player parameter. Start time becomes start= in seconds (type 1:30 or 90, both work). Autoplay adds autoplay=1, and it quietly adds mute=1 too, because Chrome, Safari, and Firefox all block unmuted autoplay. There’s no way around that, so the tool doesn’t pretend otherwise.

Loop is the sneaky one. YouTube’s loop=1 only works on playlists, so looping a single video requires playlist=VIDEO_ID with the same ID repeated. People burn twenty minutes on that quirk before finding the answer on Stack Overflow. Here it’s handled automatically.

Two more toggles matter for production sites. Privacy-enhanced mode swaps the domain to youtube-nocookie.com, which holds back tracking cookies until the visitor actually presses play. Useful for GDPR-conscious sites, and the player behaves identically. Lazy loading adds loading="lazy" so the iframe (and the few hundred kilobytes it pulls) waits until it scrolls into view. Your Core Web Vitals will thank you.

Everything runs in your browser. The URL you paste never touches a server.

When you’d use this

You’re writing a blog post in WordPress or Ghost and the default embed block doesn’t expose start time or nocookie mode. You’re building a landing page and want a muted, looping product demo with hidden controls in the hero. You’re documenting software and need lessons that open at the exact step being discussed. Or you just write HTML by hand and would rather not memorize the allow attribute string.

Course creators get particular mileage from the start time option: link lesson two straight to minute 14 of a long recording instead of telling students to scrub.

FAQ

Why does the preview not autoplay? On purpose. The preview strips autoplay so the page stays quiet while you tweak settings. The code you copy still includes it.

Does privacy-enhanced mode change playback? Nope. Same player, same features. The youtube-nocookie.com domain just delays tracking cookies until playback starts, which simplifies cookie-consent handling.

Which URL formats can I paste? Watch links, youtu.be, Shorts, embed, and live URLs all work. So does a raw 11-character video ID if that’s all you have.

My CMS strips the iframe when I paste it. What now? Use an HTML or code block instead of the visual editor. Most CMS visual modes sanitize iframes; raw HTML blocks keep them intact.

Should I use responsive or fixed size? Responsive, almost always. More than half of web traffic is mobile, and a fixed 560px iframe will overflow most phone screens. Fixed sizes only make sense inside layouts with hard pixel constraints, like email builders that support iframes.

Is there a limit on how many embeds I can generate? No. Generate as many as you want; nothing is counted or stored.

youtube embed iframe html video

Related Tools

More in Social Media Tools