YouTube Embed Code Generator
Generate custom YouTube embed codes with responsive layouts, autoplay, loop, start/end time, privacy mode, and Shorts support. Updated for 2026.
Supports: youtube.com/watch, youtu.be, youtube.com/shorts, youtube.com/playlist, or a video ID
Preview will appear here
A YouTube embed code is a snippet of HTML that displays a YouTube video player on any website. This free generator by CollabPals creates custom embed codes with responsive sizing, autoplay, loop, privacy-enhanced mode, start/end timestamps, and support for Shorts and playlists. Paste any YouTube URL, customize the player options, and copy the code. No signup required.
How to Embed a YouTube Video on Your Website
Paste Your URL
Copy the URL of any YouTube video, Shorts, or playlist and paste it into the input field above.
Customize Options
Choose responsive sizing, autoplay, loop, privacy mode, start/end time, and more. See a live preview instantly.
Copy and Paste
Click "Copy Code" and paste the HTML into your website, blog, WordPress, or any CMS. Done.
What is a YouTube Embed Code?
A YouTube embed code is an HTML <iframe> element that loads the YouTube video player inside your web page. When a visitor views the page, the embedded player loads the video directly from YouTube's servers, so you do not need to host the video file yourself. This is the officially supported method for displaying YouTube videos on external websites.
The embed code format uses YouTube's IFrame Player API, which supports dozens of parameters for customizing playback behavior, appearance, and privacy settings. Our generator handles all of these parameters visually, so you never need to edit raw HTML or memorize parameter names.
Why Responsive Embeds Matter
A standard YouTube iframe has fixed pixel dimensions (usually 560 by 315 pixels). On a mobile phone or tablet, this can cause the video to overflow the screen or display with horizontal scrolling. A responsive embed wraps the iframe in a container that scales proportionally to any screen width.
Our generator uses a CSS padding-bottom technique that maintains the 16:9 aspect ratio (or 9:16 for Shorts) regardless of screen size. This means your embedded video will look correct on every device, from a 375-pixel-wide phone to a 2560-pixel-wide monitor, without any additional CSS on your part.
Privacy-Enhanced Mode and GDPR Compliance
When you enable privacy-enhanced mode, the embed code uses youtube-nocookie.com instead of youtube.com as the embed domain. In this mode, YouTube does not store tracking cookies on your visitor's browser until they actually click play on the video.
This is important for websites that need to comply with GDPR, CCPA, or other privacy regulations. Many cookie consent tools treat YouTube embeds as third-party tracking. Privacy-enhanced mode reduces the compliance burden by deferring cookie storage until user interaction.
How Autoplay Works in 2026
Modern browsers (Chrome, Firefox, Safari, Edge) block autoplay for videos that have audio. This is a browser-level policy, not a YouTube restriction. For autoplay to work reliably, the video must also be muted. Our generator automatically enables the mute option when you toggle autoplay, ensuring the embed actually autoplays as expected.
On mobile devices, autoplay behavior varies by browser and operating system. iOS Safari generally blocks autoplay entirely, while Chrome on Android allows muted autoplay. Keep this in mind when designing pages that rely on autoplay functionality.
YouTube Embed Parameters Reference
The YouTube IFrame Player API supports the following parameters. Our generator sets these automatically based on your selected options.
| Parameter | Values | Description |
|---|---|---|
autoplay | 0 or 1 | Automatically start playing the video |
mute | 0 or 1 | Mute the video (required for autoplay) |
loop | 0 or 1 | Replay the video when it ends |
controls | 0 or 1 | Show or hide player controls |
modestbranding | 0 or 1 | Hide the YouTube logo in the control bar |
rel | 0 or 1 | Show related videos from same channel (0) or all (1) |
start | seconds | Start playback at a specific time |
end | seconds | Stop playback at a specific time |
color | red or white | Progress bar color |
disablekb | 0 or 1 | Disable keyboard shortcuts |
cc_load_policy | 0 or 1 | Show closed captions by default |
playsinline | 0 or 1 | Play inline on iOS instead of fullscreen |
Embedding YouTube Shorts
YouTube Shorts use a vertical 9:16 aspect ratio instead of the standard 16:9 widescreen format. When you paste a Shorts URL into our generator, it automatically detects the format and adjusts the embed dimensions to display the Short correctly with a vertical player.
Shorts embeds support the same parameters as regular videos: autoplay, loop, mute, privacy mode, and start/end timestamps. This makes it easy to embed Short-form content on your website, portfolio, or blog without manual aspect ratio calculations.
Embedding YouTube Playlists
You can embed an entire YouTube playlist by pasting a playlist URL. The embedded player will display the first video in the playlist and include navigation controls for viewers to browse through all videos. This is useful for course pages, music collections, or video series where you want visitors to watch multiple videos in sequence.
Frequently Asked Questions
How do I embed a YouTube video on my website?
Paste your YouTube video URL into the generator above and customize the options (size, autoplay, loop, etc.). Click "Copy Code" and paste the generated HTML iframe code into your website. The embed code works on any website, blog, CMS, or HTML page.
What is the YouTube embed code format?
YouTube embed codes use an HTML iframe element: <iframe src="https://www.youtube.com/embed/VIDEO_ID" width="560" height="315" frameborder="0" allowfullscreen></iframe>. Our generator adds responsive wrappers and additional parameters based on your selected options.
How do I make a YouTube embed autoplay?
Toggle the "Autoplay" option in our generator. This adds autoplay=1 to the embed URL. Note: most modern browsers require the video to also be muted for autoplay to work, so our generator automatically enables mute when autoplay is selected.
How do I embed a YouTube video at a specific start time?
Use the "Start Time" field in our generator to set the exact second where the video should begin playing. You can also set an "End Time" to stop playback at a specific point. These add start= and end= parameters to the embed URL.
What is YouTube privacy-enhanced mode for embeds?
Privacy-enhanced mode uses youtube-nocookie.com instead of youtube.com for the embed domain. This means YouTube will not store cookies on your visitor's browser unless they actually play the video. This helps with GDPR compliance and cookie consent requirements.
Can I embed YouTube Shorts on my website?
Yes. Paste any YouTube Shorts URL into our generator and it will automatically detect the Shorts format and generate a vertical embed with the correct aspect ratio (9:16). You can customize the same options as regular videos.
How do I make a YouTube embed responsive?
Toggle the "Responsive" option in our generator. This wraps the iframe in a container that scales to fit any screen width while maintaining the correct aspect ratio. The video will fill its container width on any device, from mobile phones to desktop monitors.
Can I embed a YouTube playlist on my website?
Yes. Paste a YouTube playlist URL into our generator. It will detect the playlist and generate embed code that plays through all videos in the playlist. The embedded player includes next/previous controls for navigating between videos.
Does the YouTube embed code work in 2026?
Yes. YouTube iframe embeds are the officially supported method for embedding videos as of 2026. Our generator uses the current YouTube Player API parameters and produces valid HTML5 code that works in all modern browsers.
How do I hide YouTube player controls in an embed?
Toggle the "Show Controls" option off in our generator. This adds controls=0 to the embed URL, removing the play/pause, volume, and progress bar from the player. The video can still be played by clicking directly on it.
How do I show captions by default on a YouTube embed?
Toggle the "Show Captions" option in our generator. This adds cc_load_policy=1 to the embed URL, which tells the YouTube player to display closed captions automatically when the video starts. This is useful for accessibility and for audiences who prefer subtitles.
More Free YouTube Tools
YouTube Thumbnail Previewer
See how your thumbnail looks in Search, Home Feed, Sidebar, and Shorts before publishing.
YouTube Title Generator
Generate click-worthy, SEO-optimized titles using 200+ proven formulas and AI.
Subscribe Link Generator
Create direct subscribe links, embed buttons, QR codes, and tracked sharing links for your channel.
YouTube Money Calculator
Estimate how much money you can earn on YouTube by views, niche, and country.
YouTube Tag Generator
Generate SEO-optimized tags using real YouTube search data, organized by category.
Hashtag Generator
Generate trending, niche, and long-tail hashtags for videos and Shorts with a built-in hashtag checker.