YouTube's own Share > Embed button gives you a fixed-size iframe with few options. This generator starts from a video or playlist URL, lets you set the player options that matter, shows a live preview and gives you clean iframe code to copy. The code works in any site builder or CMS that accepts HTML, including Shopify, WordPress and WooCommerce.
How to use the YouTube Embed Code Generator
- Paste a video URL (
youtube.com/watch?v=,youtu.be/or a Shorts link) or a playlist URL containinglist=. - Choose the options: responsive width, start time, autoplay, loop, hide controls, captions on, privacy-enhanced mode and lazy loading.
- Watch the preview update. Play it to check the start time and captions.
- Copy the code.
- Paste it into an HTML or code block on your page, not into a normal text field, where it would show as text.
In Shopify, open the product or page, click the Show HTML button (the <> icon) in the rich text editor and paste the code there. In WordPress, use a Custom HTML block.
What each option does
Most options are URL parameters documented in Google's YouTube player parameters reference. Here is what each does in practice.
| Option | Code it adds | What it does |
|---|---|---|
| Responsive width | Full width with a 16:9 aspect ratio | The player fills its container and keeps its shape on phones and desktops |
| Start time | start=90 | Starts playback at that many seconds (enter 1:30 and the tool converts it) |
| Autoplay (muted) | autoplay=1&mute=1 | Plays on page load, with sound off |
| Loop | loop=1&playlist=VIDEO_ID | Replays the video when it ends |
| Hide controls | controls=0 | Hides the control bar |
| Captions on | cc_load_policy=1 | Shows captions by default when the video has them |
| Privacy-enhanced mode | youtube-nocookie.com domain | Limits how embedded views are used for personalization |
| Lazy loading | loading="lazy" | The browser loads the player only when it nears the screen |
Autoplay needs mute
Modern browsers block autoplay with sound, so an unmuted autoplay embed usually just sits there. The generator always adds mute=1 when you turn autoplay on. Two more things to know: YouTube's help pages say autoplayed embeds do not increase the video's view count, and autoplay loads the player and starts data collection as soon as the page opens, even if the visitor never watches.
Loop needs the playlist parameter
For a single video, loop=1 only works when playlist is set to the same video ID. The generator adds it for you. For a playlist, loop replays the whole playlist.
Captions depend on the video
Captions on only works if the video has captions, either uploaded by the creator or generated automatically. If there are none, the setting does nothing.
Parameters that no longer do what people think
- rel=0 does not turn off related videos. Since 2018,
rel=0only limits them to videos from the same channel as the one playing. You cannot remove them entirely. - modestbranding is deprecated and has no effect, so the generator leaves it out.
- showinfo was removed years ago. Old tutorials still include it.
- Hiding controls does not remove the YouTube logo or the title overlay, and it does not stop visitors from clicking through to YouTube.
Note: Privacy-enhanced mode stops embedded views from shaping the visitor's YouTube recommendations and serves non-personalized ads, but it is not the same as no tracking. Once a visitor plays the video or clicks through to YouTube, normal YouTube data use applies. Check with your cookie consent setup whether it still needs consent in your region.
Embedding playlists and Shorts
For a playlist, paste the playlist URL. The code uses youtube.com/embed/videoseries?list= plus the playlist ID and shows a playlist menu inside the player. To embed a channel's latest uploads, find the channel ID with the YouTube channel ID finder, replace the leading UC with UU, and use that as the playlist ID.
Shorts embed like normal videos. Paste the Shorts link and the tool uses the video ID. Shorts are vertical, so switch the aspect ratio to 9:16 if the generator offers it, or place the player in a narrow column.
Common embedding problems
- "Video unavailable" in the player. The owner turned off embedding, the video is private, or it is blocked in the visitor's country. Unlisted videos can be embedded.
- The code shows as text. You pasted into a visual editor. Switch to HTML view.
- Tall black bars. Your theme wraps the iframe in fixed-height CSS. Use the responsive option and remove fixed width and height from the wrapper.
- Slow pages. Each player loads a large bundle of scripts. Turn on lazy loading, and avoid more than one or two embeds above the fold.
Getting the most from embedded videos
A product video on a product page can answer the questions shoppers would otherwise email you about. Keep the video close to the buy button, start it at the useful part with a start time, and write a short text summary next to it for visitors who will not press play. If you want a custom poster image, save the video's full-size thumbnail with the YouTube thumbnail downloader. To get more from the video itself on YouTube, the YouTube description generator builds a description with chapters, and YouTube Studio in AM Jarvis helps plan and write titles, descriptions and tags for the next videos.