How To (Actually) Make YouTube Video Embeds AutoPlay In 2025

The other day my boss asked me, “Can you make this video autoplay on our website?”. What I thought would be a very easy process actually took me a little bit of time to figure out, so, with this blog I intend to quickly show you how to (actually) make a YouTube video embedded on a website autoplay.

Copy this YouTube autoplay code

Here is the code you will need to modify slightly:

<iframe width="889" height="500" class="youtubeembedvideo" src="https://www.youtube.com/embed/hJEDaRbhFMo?rel=0&autoplay=1&mute=1" title="YouTube video player" frameborder="0" allow="autoplay; accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>

What parts of this code do you need to modify?

  • You will need to change part of the YouTube URL found in the src attribute above, the part immediately after “embed/”, but before “?rel=0&amp;autoplay=1&amp;mute=1”. We will call this the “YouTube video code”. This ID is a small series of letters and numbers that is unique to each YouTube video.
  • Let’s say your YouTube URL looked like this, https://youtube.com/shorts/iqrNMAw5b-0. You would copy just the YouTube video code, which (again) is everything after “shorts/” ( in this example, “iqrNMAw5b-0”) and paste it into the code above, overwriting only the code that is already there (“hJEDaRbhFMo”) with your YouTube video’s code.
  • Note: Your YouTube URL may look slightly different, depending on whether it is a regular video or a short, but the YouTube video code will always be there. For example, here is how a regular YouTube video URL may look: https://www.youtube.com/watch?v=-1ZBWUnYPbA. Despite the difference in the URL configuration, the YouTube video code is still there, right after “watch?v=” (in this case the YouTube video code would be “-1ZBWUnYPbA”.
  • Note: Do not copy anything after the YouTube video code, including any question marks. It is typical for YouTube to add a question mark after the code in their URLs with a long series of numbers after it like this example, “https://youtu.be/-1ZBWUnYPbA?si=bI59WOxGVEfYcg10“. This question mark and the code that follows it is called a “query parameter” and, in this case, is used for tracking purposes by Youtube and therefore should be excluded from the code you copy from the YouTube video URL.
  • Note: Do not delete anything from the code provided above other than the placeholder YouTube video code. Do NOT delete the question mark or anything following the question mark, and do not delete the forward slash before the YouTube video code.
  • Optional: You can change the class name (between the double quotes) to anything you would like, or simply leave it alone.
  • Note: do not change anything else in the code provided above or your video will NOT autoplay.

More Things You Need To Know

  • You can not autoplay a video with sound playing.
  • You can only autoplay a video that starts out muted. The website visitor must unmute the video themselves to hear the sound. This means they will have to rewind the video themselves too if they want to go back to the beginning of it.
  • Once again, I am serious. You can not have a video autoplay with the sound on. This isn’t the 1990’s with popups anymore. Modern browsers won’t let you do that. YouTube’s engineers have also programmed it so that this is impossible. User experience experts weep tears of sorrow every time you try to think of a way to make that work. You can’t make it work. Stop.
  • Very important: if the code above is not working on your website, one of the most common reasons is that your website is using an “ACE Editor” to handle raw HTML. When this happens the ampersands (these guys “&”) get messed up and need to be changed to look like this “&amp;” (ampersand, amp, semicolon). Try copying this code below instead of the one above and see if it works (we’ve replaced the ampersands for you).

Copy This Code if you use an ACE Editor

<iframe width="889" height="500" class="youtubeembedvideo" src="https://www.youtube.com/embed/hJEDaRbhFMo?rel=0&amp;autoplay=1&amp;mute=1" title="YouTube video player" frameborder="0" allow="autoplay; accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>

A Working Example of an Autoplaying YouTube video

Have a great day. Let us know if you have any questions about this article at eric@impactiqmarketing.ca. I hope this was helpful.

Leave a Reply

Your email address will not be published. Required fields are marked *