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.
From link to code
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.
Related tools
- YouTube Timestamp Link Maker builds links that start at a time without embedding.
- YouTube Thumbnail Grabber finds the thumbnail to show before the player loads.
- Privacy Policy Generator writes a policy that can mention embedded video.
- Cookie Policy Generator explains the cookies a player may set.
Checked against the current version of the YouTube Embed Code Generator on .

