Skip to content
TubeCrew

YouTube Embed Code Generator

Generate clean, lightweight, and 100% responsive YouTube embed codes. Customize autoplay, loop, aspect ratios, hide player controls, and enable privacy-enhanced mode.

optional

optional

Player options

Paste a video link to see the preview and the code.

YouTube’s own Share → Embed button still hands you a fixed width="560" height="315" iframe. Paste that into a modern website and it overflows on phones, letterboxes Shorts into a tiny box in the middle of the page, and loads YouTube’s full player on page load whether anyone presses play or not. I’ve set up embeds on client sites, landing pages and course platforms for years while managing more than 50 YouTube channels, and fixing that default code by hand is a job I’ve done far too many times.

This YouTube embed code generator does the fixing for you. Paste a video or Shorts link, choose your options, watch the live preview update, and copy responsive embed code that’s ready to paste into any HTML page, CMS or Tailwind project.

Tool Snapshot

Spec Details
Input Watch link, youtu.be link, Shorts link or bare video ID
Aspect ratios 16:9 Wide, 9:16 Shorts, 4:3 Classic, 1:1 Square
Timing Optional start and end time, typed as 1:30 and converted to seconds
Player options Autoplay (muted), Loop, Hide controls, Related videos from the same channel, Privacy-enhanced mode, Lazy loading
Output formats Plain iframe, Responsive CSS (aspect-ratio), Tailwind CSS
Preview Live, updates as you change settings
Cost Free, no sign-in. Runs entirely in your browser

What This Tool Does and the Problem It Solves

An embed is an <iframe> that loads YouTube’s player inside your page. Everything about how that player behaves (where it starts, whether it autoplays, whether it loops, which domain it loads from) is controlled by parameters added to the end of the embed URL. YouTube’s Share menu only exposes one of them, the start time.

The generator gives you the rest through checkboxes, writes the parameters correctly, and wraps the iframe in CSS that keeps it at the right shape on every screen size. That solves three problems I see on almost every site I audit:

  • Broken mobile layouts from fixed-width iframes.
  • Squashed Shorts embedded in a 16:9 box.
  • Slow pages from embeds that load the full player before anyone scrolls to them.

How to Generate YouTube Embed Code (Step by Step)

Paste a watch link, Shorts link, youtu.be link or the 11-character video ID into the Video link box. The preview player loads as soon as the link is recognised.

2. Choose the aspect ratio

Pick 16:9 Wide for regular videos and 9:16 Shorts for vertical videos. The 4:3 and 1:1 options suit older footage and square social clips.

3. Set timing and player options

Type a Start time and End time if you only want a section of the video to play. Then tick the options you need. Each one is explained in the cheat sheet below.

4. Pick an output format and copy

Choose the plain iframe, the Responsive CSS version or the Tailwind CSS version, then press Copy code and paste it into your page.

YouTube Iframe Parameter Cheat Sheet

These are the parameters the generator writes, and what each one actually does in YouTube’s current player.

Option in the tool Parameter added What it does Watch out for
Start time start=90 Starts playback at that second Typed times like 1:30 are converted for you
End time end=180 Stops playback at that second Viewers can still seek past it
Autoplay (muted) autoplay=1&mute=1 Plays on page load, without sound Browsers block autoplay with sound, so mute is required
Loop loop=1&playlist=VIDEO_ID Restarts the video when it ends Only works with the playlist value set to the same ID
Hide controls controls=0 Hides the player’s control bar Viewers can’t pause or seek easily, so use it for background video only
Related videos from the same channel rel=0 Limits end-screen suggestions to the same channel YouTube no longer lets embeds turn related videos off entirely
Privacy-enhanced mode youtube-nocookie.com domain Delays YouTube’s tracking storage until the viewer presses play Reduces tracking but isn’t a full cookie-consent solution on its own
Lazy loading loading="lazy" Loads the iframe only when it nears the screen Not for embeds at the very top of the page

Responsive Embeds: Why the Default Code Breaks on Mobile

The default embed sets a fixed width and height. On a phone narrower than 560 pixels, the iframe either overflows the screen or gets squashed by your theme’s CSS into the wrong shape.

The Responsive CSS output fixes this with the modern aspect-ratio property: the iframe fills the width of its container, and the browser works out the height from the ratio you chose. No padding hacks or JavaScript. The Tailwind CSS version uses aspect-video for 16:9 and aspect-[9/16] for Shorts, so it drops straight into Tailwind projects. For vertical Shorts, the generator caps the player width so a 9:16 video doesn’t stretch to the full height of a desktop screen.

Which Embed Setup Fits Your Site

Site type / creator stage Recommended setup Why
Starter (personal blog, first website) 16:9, Responsive CSS, lazy loading on Works on any theme, keeps pages light
Growing (blog posts built around your videos) Responsive CSS, start time set to the relevant section, privacy mode on Sends readers straight to the useful part
Established (landing pages, product pages) Autoplay (muted) + loop + hide controls for a hero background; normal embed for explainers Background video should feel like an image; explainers need controls
Pro (courses, membership sites, Tailwind or framework builds) Tailwind output, privacy mode on, lazy loading on below the fold Consistent with the codebase, lighter on long pages

Embedding videos on product and service pages is one of the simplest wins in our YouTube for business guide.

Embedding Shorts, Unlisted Videos and Embedding From Mobile

Embedding YouTube Shorts. Paste the Shorts link as it is. The generator converts it to a standard embed URL. Choose 9:16 Shorts so the player keeps its vertical shape instead of showing a narrow strip with black bars.

Embedding unlisted videos. Unlisted videos embed the same way as public ones; anyone who can see your page can play the video. Private videos can’t be embedded for the public.

Getting embed code on mobile. The YouTube mobile app doesn’t offer an Embed option in its Share menu. Copy the link with Share → Copy link, open this generator in your phone’s browser, and paste it. You’ll get the full embed code without switching to a desktop.

Looping a YouTube Video Without Errors

The most common looping mistake is adding loop=1 on its own. In YouTube’s embedded player, a single video only loops when the playlist parameter is also set to that video’s ID. The generator adds both automatically. Even then, loop support in iframe embeds is limited, so test it in the preview, and expect a brief pause at the restart point.

Want readers to land on one moment instead? The YouTube timestamp and chapter generator makes links and embed code that start at an exact second. And for readers and search engines, add the video’s text under the embed with the YouTube transcript generator.

Embeds and Page Speed

Each YouTube embed loads the player’s scripts and styles from YouTube’s servers. One embed is fine; five on a long article can noticeably slow the page. A few habits help:

  1. Keep lazy loading on for every embed below the first screen of the page.
  2. Avoid autoplay unless the video is the point of the page. It forces the player to load immediately.
  3. Use one embed per section rather than a stack of videos in a row.

Before embedding someone else’s video, check its title, upload date and settings, such as whether embedding is allowed, with the YouTube data viewer.

Transparency, Limitations and Edge Cases

  • Embedding disabled by the uploader. Some creators turn off “Allow embedding”. Those videos will show an error in the player no matter what code you use.
  • Age-restricted videos can’t be played inside embeds on other sites.
  • Autoplay isn’t guaranteed. Browsers, data-saver modes and some mobile settings can still block it.
  • Loop has limited support in iframe embeds, as covered above.
  • No size control. The responsive output fills its container. Set the container’s width in your own CSS to make the video smaller.
  • Single videos only. The tool is built for individual video and Shorts links.

Frequently asked questions

How do I generate embed code for a YouTube video?

Paste the video link into the generator above, choose an aspect ratio and any player options, then press Copy code. You’ll get either a plain iframe, a responsive CSS version or a Tailwind version, ready to paste into your HTML or CMS.

How do I make a YouTube embed autoplay?

Tick "Autoplay (muted)". It adds autoplay=1 and mute=1 to the embed URL. The video has to start muted, because browsers generally block autoplay with sound. Viewers can unmute it with the player controls.

How do I make an embedded YouTube video responsive?

Use the Responsive CSS output. It sets the iframe to the full width of its container and uses the CSS aspect-ratio property to keep the correct shape, so the video resizes cleanly from phones to desktops. Tailwind users can choose the Tailwind output instead.

Can I embed YouTube Shorts on my website?

Yes. Paste the Shorts link and choose the 9:16 Shorts ratio. The generator turns the Shorts link into a standard embed URL and keeps the vertical shape, with the width capped so it doesn’t take over the page on desktop.

What is privacy-enhanced mode in YouTube embeds?

It loads the player from youtube-nocookie.com instead of youtube.com. YouTube then waits until the viewer presses play before storing information in their browser. It reduces tracking on page load, but you may still need your own cookie consent setup depending on where your visitors are.