YouTube Embed Code Generator
YouTube Embed Code Generator – Create YouTube embed code for your website with a live preview. Make it responsive, start at a set time, autoplay muted, loop, turn on captions or use privacy-enhanced mode, then copy the HTML.
How to embed a YouTube video
- Paste the video link (watch, youtu.be, Shorts and live links all work).
- Choose options. The preview updates instantly.
- Copy the code and paste it into your page's HTML, or into a "Custom HTML" block in WordPress.
Options explained
| Option | Parameter | Notes |
|---|---|---|
| Start / end | start, end | In seconds; this tool converts 1:30 to 90. |
| Autoplay | autoplay=1&mute=1 | Browsers block autoplay with sound, so autoplay needs mute. |
| Loop | loop=1&playlist=ID | Loop only works when the playlist parameter repeats the video ID. |
| Controls | controls=0 | Hides the player controls. |
| Captions | cc_load_policy=1 | Shows captions by default when available. |
| Related videos | rel=0 | Since 2018, rel=0 shows related videos from the same channel rather than turning them off. |
| Privacy-enhanced | youtube-nocookie.com | YouTube doesn't store visitor information for personalisation until the video is played. |
Make embeds fast
- This code includes
loading="lazy", so the player loads only when visitors scroll near it. - Embed only the videos you need; each player adds weight to the page.
- Always add a descriptive title for screen reader users.
Responsive embeds
The responsive option wraps the player in a box with a 16:9 shape (padding-bottom: 56.25%), so it fills the width of any screen without black bars.
YouTube embed code generator: WordPress and other sites
- WordPress: add a "Custom HTML" block and paste the code. For simple embeds, pasting the video URL on its own line also works.
- Wix, Squarespace, Shopify: use the "Embed" or "Custom code" element and paste the iframe.
- Emails: iframes don't work in most email clients. Use a thumbnail image linked to the video instead.
Common mistake: pasting the normal watch URL inside an iframe. The src must use /embed/VIDEO_ID, which this tool creates for you.
Frequently asked questions
Why doesn't autoplay work with sound?
Modern browsers block autoplay with sound. Muted autoplay is allowed, which is why the tool adds mute=1.
Can I hide related videos completely?
No. Since 2018, rel=0 only limits related videos to your own channel.
Does embedding a video give its owner views?
Yes, plays of embedded videos count as views for the video owner.
Can I embed any video?
Only if the owner allows embedding. Some videos are restricted to youtube.com.