1. Home
  2. Productivity tools
  3. YouTube Embed Code Generator

YouTube Embed Code Generator

For site owners who embed videos and want clean code that respects visitors’ privacy as far as it can.

Free, no sign-up. Runs in your browser: nothing is uploaded.

Free workspace included. Docs, spreadsheets, notes and tasks that save on your device. No sign-up.Take a look

How to use YouTube Embed Code Generator

  1. Fill in the form, or press a sample to see a worked example.
  2. Read the result and any warnings.
  3. Copy the output or download it.

Features

  • Uses youtube-nocookie.com when you choose it
  • Start and stop times, loop, captions and controls
  • Autoplay with the muted flag browsers require
  • Responsive 16:9 wrapper and lazy loading
  • Title attribute for screen readers

Supported formats

Input

  • Pasted link or ID

You get

  • HTML

Private by design

Everything you enter is processed by your browser on this device. Nothing is sent to openWorkstand or anyone else, so the YouTube Embed Code Generator is safe for private and work data. After you have used it once while online, it also works without an internet connection. How local processing works

Good to know

  • The privacy-enhanced domain delays cookies until a video is played; it does not hide the embed from YouTube.
  • Autoplay works only when muted, so the tool adds the mute flag.

Guide

Embedding a YouTube video with clean, privacy-friendlier code

The embed code that YouTube gives you works, but it is fixed in size, long and leaves out choices you may want: a start time, captions on by default, a loading hint or a safer domain. This generator builds the iframe from a link and a few switches, so you get tidy code that fits any layout.

Paste the video address or its ID and a title for screen readers. The title becomes the title attribute of the iframe, which assistive technology reads to describe the video, so write something meaningful rather than leaving it blank. The tool finds the 11-character ID in the common link forms and shows the embed address it will use.

The privacy-enhanced domain

The first switch, on by default, uses youtube-nocookie.com instead of youtube.com for the embed. In this mode YouTube does not set tracking cookies in the visitor’s browser until they play the video. It does not stop the request to YouTube’s servers, and it does not make the embed invisible to Google, so a privacy policy should still mention embedded video. The note under the result says as much.

Playback options

Set a start time such as 1:30 and, if you like, an end time. Choose whether to show controls, captions by default and related videos from the same channel only (rel=0). Autoplay is available, and because browsers only autoplay muted video, the tool adds mute=1 automatically and says so. Loop repeats the video, and playsinline=1 is added so that phones play in the page rather than full screen.

Size and loading

“Responsive 16:9” wraps the iframe in a box with a 16:9 ratio that fills its container, which works in any layout. “Fixed 560 × 315” writes the traditional fixed iframe. The lazy-load switch adds loading="lazy". The iframe also carries an allow list for features such as picture-in-picture and fullscreen, and a referrer policy that sends only the site’s origin.

A worked example

The sample uses the ID dQw4w9WgXcQ and the title “How to choose running shoes” with defaults. The embed address is https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ?rel=0&playsinline=1, written with & inside the HTML. The second sample starts at 1:30 with autoplay: the address becomes https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ?start=90&rel=0&autoplay=1&mute=1&playsinline=1, because 1:30 is 90 seconds and autoplay brings the muted flag. An unreadable address shows an error that mentions the 11-character ID.

Limits

The tool creates code and never contacts YouTube, so it cannot tell whether a video is public, embeddable or still available. The player options are interpreted by YouTube and may change. Autoplay with sound is blocked by most browsers whatever you choose. If your site has a strict Content-Security-Policy, allow the embed domain in its frame rules.

Placing the code

Paste the finished block where you want the video to appear in the page source. With the responsive size, the surrounding box adapts to the width of its column, so you can put it in a narrow article or a wide layout without editing the numbers. Check the result on a phone as well as a computer, and confirm that the video plays before you publish.

Checked against the current version of the YouTube Embed Code Generator on .

Frequently asked questions

Does the embed make my page slower?

A YouTube player loads a good deal of script and data. The lazy-loading option adds loading="lazy" to the iframe so that browsers fetch it only when it is about to scroll into view, which helps pages with the video far below the top.

What does rel=0 do now?

It limits the related videos shown at the end to videos from the same channel, instead of videos from anywhere. It no longer removes them entirely, so do not expect an empty end screen.

Does the privacy-enhanced domain make the embed private?

It stops YouTube setting cookies until a visitor plays the video, but it does not hide the embed from YouTube, so you may still need to mention it in your privacy policy.

Why does autoplay add mute?

Browsers allow autoplay only for muted videos, so the tool adds mute=1 whenever autoplay is on.

Keep working with the result

openWorkstand also includes a free workspace with documents, spreadsheets, tasks, projects and a calendar that save to a folder on your computer.