YouTube Embed Code Generator

Build the embed code for any YouTube video or Short, with a start time, autoplay, loop and privacy-enhanced mode, and see a live preview.

Works with watch, Shorts, Live and youtu.be links, or an 11-character video ID.

Options

How it works

How to embed a YouTube video

Responsive by default, so the player fits every screen.

  1. Copy the video link

    Copy the link of the YouTube video or Short you want to put on your page.

  2. Choose options

    Paste it above and set a start time, autoplay, loop or any other option. The code updates as you go.

  3. Copy the code

    Copy the embed code and paste it into your page's HTML, or a "Custom HTML" block in WordPress, Wix or Webflow.

Good to know

YouTube embed options, explained

What each option does

  • Start at / End at: plays only part of the video. Enter times like 90, 1:30 or 1m30s.
  • Responsive size: the player fills the width of its container and keeps a 16:9 shape (9:16 for Shorts), so it fits phones and desktops. Turn it off for a fixed 560 × 315 player.
  • Privacy-enhanced mode: uses youtube-nocookie.com. YouTube says it doesn't store information about visitors on your page unless they play the video.
  • Show player controls: turn off to hide the progress bar and buttons, for a cleaner background video.
  • Autoplay: browsers only autoplay video without sound, so autoplay always adds mute.
  • Loop: replays the video when it ends. YouTube needs the video ID repeated as a playlist for this, which the code does for you.
  • Captions on: shows captions by default, when the video has them.

Embedding a YouTube Short

Paste a Shorts link and the code switches to a vertical 9:16 player, so the Short isn't letterboxed inside a wide frame.

Where to paste the code

  • WordPress: add a Custom HTML block.
  • Wix, Squarespace, Webflow: use the Embed or Code element.
  • Your own site: paste it into the HTML where the video should appear.

When a video won't embed

Creators can turn embedding off. Those videos show "Video unavailable" in the player, and only the creator can change that.

FAQ

Embed code questions

How do I embed a YouTube video?

Paste the video's link above, choose your options and copy the code. Paste it into your page's HTML or a "Custom HTML" block in your site builder.

How do I make a YouTube embed start at a specific time?

Enter the time in Start at, for example 1:30. If your link already has a time in it (?t=90), it's filled in for you.

Why doesn't autoplay work with sound?

Browsers block autoplay with sound, so an embed can only autoplay muted. That's why choosing autoplay also mutes the video.

What is privacy-enhanced mode?

An embed served from youtube-nocookie.com. According to YouTube, it doesn't store information about your visitors unless they play the video, which helps with privacy rules such as the GDPR.

How do I make a YouTube embed responsive?

Leave Responsive size on. The code wraps the player so it fills the width of the page and keeps its shape on every screen.