YouTube's own Share > Embed button gives you a fixed 560 by 315 pixel iframe with few options. This generator starts from any video, Short or playlist URL, lets you set the player options that matter, shows a live preview and gives you clean code to copy. The code works in any site builder or CMS that accepts HTML, including Shopify, WordPress, WooCommerce, Wix, Squarespace and plain HTML pages.
Everything happens in your browser. The only request that leaves the page is the preview player loading from YouTube.
How to use the YouTube Embed Code Generator
- Paste a link. Watch links,
youtu.belinks, Shorts, live links, existing embed links and playlist links withlist=all work. The badge under the box confirms whether it found a video, a Short, a playlist, or a video inside a playlist. - Choose the size. Responsive fills the width of its container and keeps its shape. Fixed lets you set width (200 to 3,840 pixels) and height (150 to 3,840 pixels).
- Choose the aspect ratio. 16:9 for normal videos, 9:16 for Shorts. A Shorts link switches to 9:16 automatically, and the vertical player is capped at 360 pixels wide so it does not fill a desktop screen.
- Set a start time if you want playback to begin partway through. Type
1:30,1:02:30,1m30sor plain seconds. If your link already has?t=, the start time fills in for you. - Tick the options you want: autoplay (muted), loop, hide controls, captions on, privacy-enhanced mode, lazy loading, and related videos from this channel only.
- Edit the player title. Screen readers announce it, so describe the video, for example "How to fit a bike chain".
- Play the preview to check the start time and captions, then click Copy code. Copy player URL copies just the src address if your platform has its own video block that asks for a URL.
- Paste the code into an HTML block, not a normal text field, where it would show as text.
Where to paste the code
| Platform | Where the code goes |
|---|---|
| Shopify product or page | Open the rich text editor, click Show HTML (the <> icon) and paste. In a theme section, use a Custom Liquid block. |
| WordPress and WooCommerce | Add a Custom HTML block in the block editor, or use the Text tab in the classic editor. |
| Wix, Squarespace and similar | Use the Embed or Code block and paste the whole snippet. |
| Plain HTML site | Paste it where the player should appear inside the page body. |
What each option does
Most options are URL parameters documented in Google's YouTube player parameters reference.
| Option | Code it adds | What it does |
|---|---|---|
| Responsive | A wrapper that keeps a 16:9 or 9:16 ratio | The player fills its container on phones and desktops |
| Start time | start=90 | Starts playback at that many seconds |
| Autoplay (muted) | autoplay=1&mute=1 | Plays on page load with sound off |
| Loop | loop=1&playlist=VIDEO_ID | Replays the video, or the whole playlist |
| 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 (on by default) | youtube-nocookie.com | Views do not shape the visitor's YouTube recommendations or ads elsewhere |
| Lazy loading (on by default) | loading="lazy" | The browser loads the player only when it nears the screen |
| Related videos from this channel only | rel=0 | Limits end-screen suggestions to the same channel |
The code also includes referrerpolicy="strict-origin-when-cross-origin", the same value YouTube's own embed code uses, and an allow list for fullscreen, picture-in-picture and autoplay.
Worked examples
A product video that starts at the demo
A Shopify seller has a 6-minute unboxing video where the useful demo starts at 1 minute 45 seconds. She pastes the link, types 1:45 as the start time (the hint confirms 105 seconds), keeps responsive and privacy-enhanced mode, and pastes the code under the product description. Shoppers who press play see the product working, not the packaging.
A looping background clip
A cafe website wants a silent 20-second latte art clip playing on its homepage. Tick autoplay and loop, and hide controls. The generator adds mute=1 for autoplay and playlist= with the same video ID, which YouTube needs to loop a single video.
A Short on a blog post
A recipe blogger pastes a Shorts link. The tool detects it, switches to 9:16 and builds a vertical player capped at 360 pixels wide and centered, so the Short looks the way it does on a phone.
Autoplay, loop and captions: the fine print
Autoplay needs mute. Browsers block autoplay with sound, so the generator always adds mute=1. YouTube's embedding help page also says embedded videos that are autoplayed do not increase the view count, and autoplay loads the player as soon as the page opens, even if the visitor never watches.
Loop needs the playlist parameter for a single video. The generator adds it. For a playlist, loop replays the whole list.
Captions on only works if the video has captions, uploaded or automatic.
Parameters that no longer do what people think
- rel=0 does not turn off related videos. Since 2018 it only limits them to the same channel as the video playing.
- 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 title overlay, and visitors can still click through to YouTube.
Note: Privacy-enhanced mode stops embedded views from shaping the visitor's YouTube recommendations and from personalizing ads outside your site, 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 whether your cookie consent setup still needs to cover it in your region.
Embedding playlists and a channel's latest uploads
Paste a playlist URL and the code uses youtube.com/embed/videoseries?list= plus the playlist ID, with a playlist menu inside the player. Paste a watch link that also contains list= and the player starts on that video inside the playlist. To show a channel's newest uploads, find the channel ID with the YouTube channel ID finder, copy its uploads playlist (the ID with UC changed to UU) and paste youtube.com/playlist?list= plus that ID here.
Who uses it
- Online store owners adding product demos and how-to videos next to the buy button.
- Bloggers and affiliate site owners embedding reviews to keep readers on the page.
- Teachers and course creators starting a lesson video at the exact part students need.
- Creators putting their latest uploads on their own website or link-in-bio page.
- Developers who want clean, accessible code without writing the wrapper by hand.
Troubleshooting
- "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.
- "Error 153: Video player configuration error". YouTube could not read where the player is embedded. Keep the
referrerpolicyattribute from the generated code, and check that your site, a security plugin or a server setting is not sendingReferrer-Policy: no-referrerorsame-origin. - The code shows as text. You pasted into a visual editor. Switch to HTML view.
- Black bars or a squashed player. Your theme sets a fixed height on the iframe. Use the responsive option and remove fixed sizes from the surrounding block.
- Autoplay does not start. Some mobile browsers and data saver modes still block it, even muted.
- Slow pages. Each player loads a large bundle of scripts. Keep lazy loading on and avoid more than one or two embeds above the fold.
Getting the most from embedded videos
Keep a product video close to the buy button, start it at the useful part and write a short text summary next to it for visitors who will not press play. Save a full-size poster image with the YouTube thumbnail downloader if your theme uses one. On YouTube itself, a clear description with chapters from the YouTube description generator helps the same video get found, and YouTube Studio in AM Jarvis plans and writes titles, descriptions and tags for the next videos.