Copying YouTube's own "Embed" code gives you a fixed 560 × 315 box that can overflow on phones and loads tracking from youtube.com straight away. A better embed is responsive, uses privacy-enhanced mode, has an accessible title and lazy-loads.

The YouTube Embed Code Generator produces that version from any YouTube link in a few clicks. You paste the link, tick the options you need, and copy clean HTML that works in WordPress, Blogger, Wix custom code blocks or a hand-written site.

Why the default embed is not enough

The standard snippet from YouTube's Share menu works, but has a few weak points for modern sites:

  • Fixed width and height. On a narrow phone screen a 560-pixel player can break the layout or be squashed.
  • No lazy loading. The player starts loading even if the video sits far down the page.
  • A generic title. Screen-reader users hear "YouTube video player" for every video on the page.
  • Standard domain. It uses youtube.com rather than the privacy-enhanced youtube-nocookie.com.

The generator fixes all four by default and adds options YouTube's own dialog does not expose, such as stop time and caption language.

Creating your embed code

  1. Open the YouTube Embed Code Generator.
  2. Paste a YouTube link or video ID. Watch links, youtu.be short links, Shorts, live and embed URLs all work; a green note confirms the video ID (and playlist, if any).
  3. Choose a Player size: Responsive 16:9, Responsive 9:16 (Shorts) or Fixed size. Fixed size reveals Width (px) and Height (px) fields.
  4. Optionally set Start at and Stop at using formats like 1:30, 90 or 1m30s. If the link already contains a start time, it is used automatically.
  5. Type a Title for screen readers that describes the video, such as "How to make a pivot table".
  6. Pick your Options (explained below), plus a Caption language and Player language if you want them. Indian languages from Hindi and Bengali to Odia and Assamese are in the list.
  7. Press Copy code and paste it into your page's HTML.

The code box updates live as you change settings. If something is off, such as a stop time before the start time or a missing title, a message appears beneath it.

What each option does

Option Effect in the code
Privacy-enhanced mode (youtube-nocookie.com) Loads the player from youtube-nocookie.com
Lazy-load Adds loading="lazy" so the player loads when scrolled near
Autoplay (also mutes the video) Adds autoplay=1, mute=1 and playsinline=1
Start muted Adds mute=1 without autoplay
Loop the video Adds loop=1 and the required playlist= parameter
Hide player controls Adds controls=0
Show captions by default Adds cc_load_policy=1
Related videos from the same channel only (rel=0) Adds rel=0

Privacy-enhanced mode and lazy loading are ticked by default. Two details trip many people up. First, looping a single video only works when the playlist parameter repeats the same video ID, which the tool adds for you. Second, autoplay with sound is blocked by browsers, so ticking Autoplay also ticks Start muted.

Previewing safely

The Preview panel stays empty until you press Load preview. Until then, nothing at all is requested from YouTube, which suits anyone checking settings on a work network or simply preferring not to load third-party scripts. Once loaded, YouTube's player runs in your browser under YouTube's own privacy policy, and the preview refreshes as you change options.

How the responsive version works

For 16:9 videos, the tool wraps the iframe in a container whose top padding is 56.25% of its width. Because padding percentages are based on width, the box always keeps a 16:9 shape, and the iframe fills it absolutely. For Shorts, the padding is 177.78% (16 ÷ 9) inside an outer box limited to 360 pixels wide, so a vertical video does not stretch the full width of a desktop article. The code uses only inline styles, which means you do not need to touch your theme's CSS.

Practical tips

  • Write a real title. "Kolkata tram ride, Esplanade to Shyambazar" helps screen-reader users and is more meaningful than the default.
  • Use start and stop times for tutorials. Embedding just the 40 seconds that answer a reader's question is often more useful than the full video.
  • Avoid autoplay on articles. Readers who came to read can find it distracting. Keep it for landing pages where the video is the main content.
  • Be careful with hidden controls. Without controls, visitors can start a video by clicking, but pausing becomes awkward. The tool warns you about this.
  • Check your consent setup. If your site uses a cookie banner, privacy-enhanced mode reduces but does not remove the need to mention embedded YouTube players.

Mistakes to avoid

  • Pasting a channel or search URL. Only video and playlist links can be embedded; the tool says clearly when a link is neither.
  • Embedding videos you are not allowed to show. The owner can disable embedding, and the video's terms still apply on your site.
  • Stacking many embeds on one page. Even with lazy loading, ten players add weight. Link to the rest instead.
  • Forgetting mobile. Always look at the page on a phone after pasting, especially if you chose a fixed size.

If you only need a link that opens at a particular moment, rather than a player on your page, the YouTube Timestamp Link Generator is quicker. To pull clean video IDs from a long list of links before embedding them, use the YouTube URL & Video ID Extractor. Both, like this generator, run in your browser with no sign-up.