YouTube Embed Code Generator

Generate the HTML embed code for a YouTube video with custom width, height, autoplay and other options.

How to use

  1. Paste a YouTube URL or video ID.
  2. Set the width, height and options (autoplay, loop, controls).
  3. Copy the generated iframe embed code for your website.

About this tool

YouTube provides an embed code for every public video, but the default code is not always what you want. This generator lets you customise the dimensions, enable or disable autoplay, loop, related videos and player controls, and outputs a clean iframe tag ready to paste.

The embed uses YouTube's privacy-enhanced mode (youtube-nocookie.com) by default, which does not set tracking cookies until the viewer clicks play.

For responsive design, wrap the iframe in a container with padding-top: 56.25% (16:9 aspect ratio) and set the iframe to position:absolute, width:100%, height:100%.

Frequently asked questions

What is the privacy-enhanced mode?

It uses youtube-nocookie.com instead of youtube.com. No tracking cookies are set until the viewer clicks play.

How do I make it responsive?

Wrap the iframe in a div with padding-top:56.25% and position:relative. Set the iframe to position:absolute, width:100%, height:100%.

Can I hide the YouTube logo?

Partially — the modestbranding parameter used to hide it, but YouTube deprecated it in 2023.

Related tools

Long links? Shorten them for free

Vai.la turns any URL into a short link with click statistics, QR Code and your own biolink.

Vai.la is not responsible for how the tools are used or for decisions made based on their results.