SimpleWeb.tools

YouTube Embed Code Generator

YouTube embed code generator creates customizable iframe codes for embedding videos on your website. Paste any YouTube URL, adjust size, enable autoplay, hide controls, and more. Copy the generated code and paste it into your HTML—simple and fast.

Video preview will appear here

How to embed a YouTube video on your website

  1. Copy the video's link from YouTube (the address bar or the Share button).
  2. Paste it into the URL field above and choose a size, or pick a preset.
  3. Turn on the options you need, such as autoplay, loop or a start time.
  4. Click Generate Embed Code and check the preview.
  5. Click Copy and paste the code into your page's HTML where the video should appear.

How to make a YouTube embed responsive

A fixed width can overflow on phones. Choose the Responsive (100% width) preset and the generator wraps the iframe in a container that keeps the 16:9 shape and scales to the width of its parent. The result looks like this:

<div style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;">
  <iframe style="position:absolute;top:0;left:0;width:100%;height:100%;"
    src="https://www.youtube.com/embed/VIDEO_ID"
    title="YouTube video player" loading="lazy"
    referrerpolicy="strict-origin-when-cross-origin"
    allowfullscreen></iframe>
</div>

Embedding in WordPress, Wix, Squarespace and Notion

  • WordPress: add a Custom HTML block and paste the code.
  • Wix: add an HTML embed element, choose the code option, and paste the code.
  • Squarespace: add a Code block and paste the code.
  • Notion: paste the plain video link and choose to create an embed. You don't need the iframe code.

Fixing "Error 153: Video player configuration error"

This error usually means YouTube's player did not receive the referrer information it needs. The code from this tool includes referrerpolicy="strict-origin-when-cross-origin", which is what YouTube recommends. If you still see the error:

  • Check that your site is not sending a strict Referrer-Policy header such as no-referrer or same-origin. Use strict-origin-when-cross-origin instead.
  • Make sure the embed code kept the referrerpolicy attribute when you pasted it into your editor.
  • Test on a live web address. Opening an HTML file straight from your computer can also cause this error.
  • If your site uses a Content Security Policy, allow youtube.com and youtube-nocookie.com in frame-src.

Why autoplay or loop doesn't work

Most browsers only allow autoplay when the video is muted, so this tool turns on mute when you enable autoplay. Some mobile browsers still block it. Looping a single video needs a playlist parameter with the same video ID, which the generator adds for you.

More YouTube tools

Working with YouTube videos? Try the video statistics checker, the timestamp link generator, the title and description extractor, or the earnings calculator.

Frequently Asked Questions

How do I embed a YouTube video on my website?
Paste your YouTube video URL into the tool, customize the settings (size, autoplay, etc.), click "Generate Embed Code," then copy the iframe code and paste it into your website's HTML where you want the video to appear.
What's the difference between autoplay and mute?
Autoplay makes the video start playing automatically when the page loads. Most browsers require videos to be muted for autoplay to work, so it's recommended to enable both options together.
What are the best embed dimensions?
The default 560×315 works well for most websites. For HD quality, use 1280×720. For responsive designs that adapt to screen sizes, choose the "Responsive (100% width)" preset.
Can I start the video at a specific time?
Yes! Enter the start time in seconds. For example, to start at 1 minute and 30 seconds, enter "90" in the Start Time field.
What does "Modest branding" do?
This is a legacy YouTube option meant to make the logo less prominent in the control bar. YouTube has been phasing it out, so it may have little or no visible effect. It is kept here for older setups.
Can I turn off related videos completely?
Not entirely. Leaving the related-videos option unchecked adds rel=0, which limits end-of-video suggestions to your own channel instead of other channels.
What is privacy-enhanced mode?
It switches the embed to youtube-nocookie.com. YouTube states that this domain does not store information about visitors on your site unless they play the video. It is a good choice if you care about visitor privacy.
Will embedded videos work on mobile devices?
Yes! YouTube embeds are fully responsive and work on all modern devices including smartphones and tablets. Use the responsive width option for best mobile experience.