How to Embed a YouTube Video with Sound Muted

It is easy to embed YouTube videos in your website. You just have to copy the IFRAME embed code and paste it anywhere on your web page. YouTube does offer basic customization options - like you can modify the player dimensions or hide the YouTube branding - but if you would like to have more control over the layout or behavior of the embedded player, YouTube Player API is the way to go.

This tutorial explains how you can embed a YouTube video that will automatically play when the web page is loaded but with muted audio.

For instance, a products website may use short screencasts to highlight features and these videos will autoplay when the page is loaded. The volume is however set to 0 and the user can manually click to unmute the video. Similarly, if you are using YouTube video backgrounds, it makes more sense to embed muted videos that run in a loop.

Embed YouTube Player with Autoplay and Sound Muted

See the demo page to get an idea of what we are trying to do here. The page loads, the video plays but with the audio slide is all the way down.

This is easy. Go the YouTube video page and note down the ID of the video from the URL. For instance, if the YouTube video link is, the YouTube video id is xyz. Once you have the ID, all you have to do is replace YOUR_VIDEO_ID in the following code with that string.

<div id="muteYouTubeVideoPlayer"></div>

<script async src=""></script>
  function onYouTubeIframeAPIReady() {
    var player;
    player = new YT.Player('muteYouTubeVideoPlayer', {
      videoId: 'YOUR_VIDEO_ID', // YouTube Video ID
      width: 560, // Player width (in px)
      height: 316, // Player height (in px)
      playerVars: {
        autoplay: 1, // Auto-play the video on load
        controls: 1, // Show pause/play buttons in player
        showinfo: 0, // Hide the video title
        modestbranding: 1, // Hide the Youtube Logo
        loop: 1, // Run the video in a loop
        fs: 0, // Hide the full screen button
        cc_load_policy: 0, // Hide closed captions
        iv_load_policy: 3, // Hide the Video Annotations
        autohide: 0, // Hide video controls when playing
      events: {
        onReady: function (e) {

  // Written by @labnol

Next place the edited code on your web page and the embedded video would automatically play but the sound is muted.

You can further customize the player by modifying the various player variables as commented in the code. For instance, if you set loop as 1, the video will play in a loop. Set fs to 1 to show the fullscreen button inside the video player. Internally, the player is embedded using the YouTube IFRAME API. When the page is loaded, the onReady event runs that mutes the video.

youtube-mute-video-embed.png The embedded YouTube video will autoplay, but muted.

Amit Agarwal

Amit Agarwal

Google Developer Expert, Google Cloud Champion

Amit Agarwal is a Google Developer Expert in Google Workspace and Google Apps Script. He holds an engineering degree in Computer Science (I.I.T.) and is the first professional blogger in India.

Amit has developed several popular Google add-ons including Mail Merge for Gmail and Document Studio. Read more on Lifehacker and YourStory


Awards & Titles

Digital Inspiration has won several awards since it's launch in 2004.

Google Developer Expert

Google Developer Expert

Google awarded us the Google Developer Expert award recogizing our work in Google Workspace.

ProductHunt Golden Kitty

ProductHunt Golden Kitty

Our Gmail tool won the Lifehack of the Year award at ProductHunt Golden Kitty Awards in 2017.

Microsoft MVP Alumni

Microsoft MVP Alumni

Microsoft awarded us the Most Valuable Professional (MVP) title for 5 years in a row.

Google Cloud Champion

Google Cloud Champion

Google awarded us the Champion Innovator title recognizing our technical skill and expertise.

Email Newsletter

Sign up for our email newsletter to stay up to date.

We will never send any spam emails. Promise.