Skip to content

Free YouTube Embed Code Generator

Paste a YouTube link or video ID, choose how the player behaves, and copy ready-to-paste embed code. It handles start and end times, autoplay, looping, captions, privacy-enhanced mode, responsive sizing and 9:16 Shorts.

  • Free
  • No sign-up
  • Runs in your browser

Works with watch, youtu.be, Shorts, live and embed links. Timestamps like ?t=90 carry over.

How to use it

How to use the YouTube Embed Code Generator

  1. Paste the video link

    Watch, youtu.be, Shorts, live and embed links all work, or paste just the 11-character video ID. A timestamp in the link becomes the start time.

  2. Set the player options

    Pick a start and end time, autoplay, mute, loop, hidden controls and captions. Privacy-enhanced mode and lazy loading are on by default.

  3. Choose a size

    Use a responsive player that fills the width of its container, or set a fixed width and height. Switch to 9:16 for Shorts.

  4. Copy and paste

    Copy the code into your page's HTML. The preview plays the video with your settings, except autoplay.

Which YouTube embed parameters still work?

The generator uses the parameters YouTube documents for its embedded player:

Older parameters such as modestbranding and showinfo are deprecated and do nothing, so the generator leaves them out. The Start muted option adds mute=1, which isn't on YouTube's documented list. It's widely used, but treat it as best effort.

  • start and end: whole seconds, and end counts from the beginning of the video, not from the start time
  • autoplay=1: plays on load, though browsers usually block it unless the video is muted
  • loop=1: repeats the video, and a single video only loops when playlist is set to its own ID
  • controls=0: hides the player controls
  • cc_load_policy=1: shows captions by default

What is privacy-enhanced mode?

Privacy-enhanced mode loads the player from youtube-nocookie.com instead of youtube.com. YouTube says views in this mode aren't used to personalize the viewer's YouTube experience, and any ads shown are non-personalized.

It doesn't change your other obligations. If your site is aimed at children, YouTube still requires you to designate it as child-directed.

Why won't my embedded YouTube video play?

The common causes, from YouTube's help center and developer policies:

  • The owner turned off embedding by unchecking Allow embedding in YouTube Studio
  • The video is age-restricted, and those can't be watched on most third-party sites
  • Error 153 means the page sent no referrer; the generated code uses strict-origin-when-cross-origin, the policy YouTube recommends
  • The player is smaller than YouTube's 200 x 200 pixel minimum; for 16:9 it recommends at least 480 x 270

A few more things

Good questions. Clear answers.

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

Enter a start time like 1:30, or paste a link that already has a timestamp such as ?t=90. The code adds start=90, the time in seconds.

Why doesn't autoplay work in my embed?

Most browsers block videos that autoplay with sound, so turn on Start muted along with Autoplay. Also note that YouTube doesn't count autoplayed embeds as views.

How do I loop an embedded YouTube video?

Turn on Loop. A single video only loops when the playlist parameter is set to its own ID, so the generator adds both loop=1 and playlist for you.

How do I make a YouTube embed responsive?

Choose Responsive. The player sits in a container with a 16:9 aspect ratio, or 9:16 for Shorts, so it scales with the width of your page.

Can I embed a YouTube Short?

Yes. Paste the Shorts link and the generator switches to a 9:16 player, capped at 360 pixels wide in responsive mode so it doesn't fill a desktop screen.

Does this tool send anything to YouTube?

The code is built in your browser. The only request to YouTube is the preview player, which loads from youtube-nocookie.com after you paste a video.

Your next great video starts with a little inspiration.

Find a promising idea, make it your own, and bring it to life. Your creative process has a home in Vidfora.

Get started free