Skip to content

YouTube Embed Code Generator

Paste a YouTube link, choose your player options and copy clean, responsive embed code for your website or blog.

  • 100% free
  • Runs in your browser
  • Instant results
2 Player options
3 Embed code
Code appears here
Quick answer

A YouTube embed code generator turns a video link into the iframe HTML you paste into a web page. This one reads the video ID from any YouTube URL, including Shorts and youtu.be links, and builds responsive or fixed-size code with optional start time, autoplay, mute, loop, hidden controls and privacy-enhanced mode.

How to use the YouTube Embed Code Generator

  1. Paste the YouTube linkAny format works: a watch link, a youtu.be link, a Shorts link or the 11-character video ID.
  2. Choose the sizeKeep Responsive so the player fits any screen, and pick 16:9, 9:16 or 4:3. Or set a fixed width and height.
  3. Set player optionsAdd a start time and switch privacy-enhanced mode, controls, autoplay, mute and loop on or off.
  4. Copy the codePress Copy code and paste it into the HTML of your page. Use Preview to check it first.

What the YouTube embed code generator produces

YouTube’s own Share → Embed button gives you a fixed 560 × 315 player. On a phone that box is wider than the screen, and on a large monitor it looks small. The YouTube embed code generator wraps the player in a container that uses the CSS aspect-ratio property, so the video fills the width of its column and keeps its shape on every device:

<div style="position:relative;width:100%;aspect-ratio:16/9;">
  <iframe style="position:absolute;top:0;left:0;width:100%;height:100%;"
    src="https://www.youtube-nocookie.com/embed/VIDEO_ID" …></iframe>
</div>

For Shorts, choose 9:16 and the code also limits the width so a vertical video does not fill a desktop screen. The tool builds the code in your browser. It does not contact YouTube until you press Preview.

Player options explained

  • Privacy-enhanced mode loads the player from youtube-nocookie.com. YouTube then does not use viewing of the embedded video to personalise the visitor’s browsing unless they press play. It is a sensible default on sites with visitors in the EU or UK, though you may still need to mention the embed in your cookie notice.
  • Start at adds start= in seconds. Type 1:30, 90 or 1m30s. To share a moment as a link instead, use the YouTube timestamp link generator.
  • Autoplay adds autoplay=1. Browsers block autoplay with sound, so the tool also adds mute=1. Autoplayed embeds do not count as views in the usual way.
  • Loop adds loop=1 together with playlist=VIDEO_ID, which YouTube requires for a single video to repeat.
  • Player controls off adds controls=0 and hides the bar at the bottom of the player.

Paste the code into an HTML block: the Custom HTML block in WordPress, an Embed or Code block in Squarespace, Wix, Webflow or Shopify, or straight into your template. If the owner has switched off embedding, the player shows “Video unavailable” and only the owner can change that. Need the preview image as well? Use the YouTube thumbnail downloader.

Frequently asked questions

How do I embed a YouTube video on my website?

Paste the video link into the YouTube embed code generator, choose your options and copy the iframe code. Then paste it into an HTML or embed block where you want the video to appear.

How do I make a YouTube embed responsive?

Put the iframe inside a container with width 100% and a CSS aspect-ratio of 16/9, and make the iframe fill it. The Responsive option in this tool writes that code for you.

Why does autoplay not work?

Browsers only allow videos to start automatically when they are muted, and some block it entirely on mobile data. The tool adds mute=1 with autoplay to give it the best chance.

What is privacy-enhanced mode?

It serves the player from youtube-nocookie.com, which limits the tracking YouTube does before a visitor plays the video. The video itself plays the same way.

Can I embed a YouTube Short?

Yes. Paste the Shorts link and the tool selects the vertical 9:16 shape automatically. The embed uses the normal player.

Last updated 24 November 2026 by the TheTechFolk team.