YouTube Embed Code Generator
Customize your video player with autoplay, start times, and privacy-enhanced mode. Responsive 16:9 layouts ready to copy.
Preview
Paste a YouTube URL above to see the preview
Customize
Autoplay
Start video on load
Muted
Required for autoplay
Show controls
Play/Fullsreen/Vol
Loop
Replay when finished
Allow fullscreen
Enable full interface
Same-channel related
No competitor videos
Privacy-enhanced
GDPR/No cookie mode
Embed code
// Paste a YouTube URL to see the codeAccessibility: Code includes a title attribute on the iframe, a WCAG requirement.
How to Embed a YouTube Video on a Website
Paste the URL
Copy the video URL from YouTube and paste it above. We support /watch, /shorts, and /embed formats.
Customize player
Choose size, toggle autoplay, set start/end times, and enable privacy-enhanced mode.
Copy the code
Pick your format (HTML, WordPress, Markdown, or React) and paste the code into your site's editor.
YouTube Embed Parameters Reference
| Parameter | Values | Description |
|---|---|---|
| autoplay | 0 or 1 | Auto-start on load. Most browsers require mute=1 to work. |
| mute | 0 or 1 | Start video muted. Required for autoplay in Chrome and Safari. |
| controls | 0 or 1 | Show or hide play, volume, and progress bar. |
| loop | 0 or 1 | Loop video. Requires playlist=VIDEO_ID for single videos. |
| start | Seconds | Playback starts at the specified offset. |
| end | Seconds | Playback stops at the specified offset. |
| rel | 0 or 1 | 0 shows same-channel related videos only. |
| fs | 0 or 1 | Toggle the fullscreen button availability. |
| playlist | ID | Required for looping a single video automatically. |
| cc_load | 1 | Show closed captions by default if available. |
Responsive YouTube Embed CSS
Modern websites need videos that scale flawlessly across mobile and desktop. Choose your preferred CSS implementation:
Classic method (Works Everywhere)
.video-container {
position: relative;
width: 100%;
padding-bottom: 56.25%; /* 16:9 */
height: 0;
overflow: hidden;
}
.video-container iframe {
position: absolute;
top: 0; left: 0;
width: 100%; height: 100%;
border: 0;
}Modern method (aspect-ratio)
.video-container iframe {
width: 100%;
aspect-ratio: 16 / 9;
border: 0;
}Supported in all modern browsers. Simpler code, same result.
Privacy-Enhanced Mode
Enable the "Privacy-enhanced mode" toggle to use youtube-nocookie.com.
What it does
- YouTube won't set tracking cookies until play is clicked.
- Reduces your site's cookie footprint for GDPR.
- Functions identically to standard embeds.
What it doesn't do
- It doesn't block all tracking. Once played, cookies are set.
- It doesn't prevent YouTube from logging view data.
- It doesn't replace a full GDPR consent banner.
Frequently Asked Questions
Generate the code using the tool above, copy the HTML snippet, and paste it into yours site's HTML editor. If you use a CMS like WordPress, use the 'Custom HTML' block.
Browsers block autoplay with sound by default. You MUST enable 'Muted' alongside 'Autoplay' for it to work reliably in Chrome, Safari, and Firefox.
The classic default is 560 × 315 pixels (16:9). However, we recommend using 'Responsive' mode for modern websites.
Select the Responsive option in the generator. It adds a CSS wrapper that maintains the 16:9 ratio at any screen width.
Yes. Paste the Shorts URL and it will be converted into a standard player embed. It will play with black bars on the sides.
No. Everything runs in your browser using standard IFrame parameters. No accounts or software required.
Build YouTube Tools with an API
Need video metadata, chapters, or engagement data at scale? Growati's API delivers clean JSON for millions of videos.