YouTube Embed Code Generator

Paste a YouTube URL to create embed code (an iframe) for your blog or website. Set the start and end time, autoplay, loop, captions and responsive sizing while checking a live preview, and create share links that start at a specific time.

Paste a video page URL, a share link (youtu.be), a Shorts, live or playlist URL, an 11-character video ID, or even embed code (iframe) you already use.

Playback range

Use h:mm:ss or m:ss (such as 1:23 or 0:01:23), plain seconds (83) or 1m23s. The end time is measured from the beginning of the video. Leave blank for none.

Size

Fills the width of its container and sets the height from the aspect ratio (CSS aspect-ratio). It never overflows on phones or desktops.

Caps the width on large screens and centers the player. Choosing vertical (9:16) fills in 360 automatically.

Playback

Starts playing as soon as the page loads. Most browsers block autoplay with sound, so turning this on also turns on Mute.

Starts playback with the sound off. Viewers can turn the sound on with the volume button.

Plays the video again from the start when it ends. For a single video, loop=1 is written together with playlist=(the same video ID).

Plays the video inside the page on iPhone instead of switching to full screen.

Player display

Turn this off to hide the controls (controls=0) — handy for background-style videos.

Shows captions even if the viewer has turned them off. Videos without captions are unaffected.

The preferred caption language (cc_lang_pref). It has no effect if the video has no captions in that language. "Not set" follows the viewer's settings.

The language of the player's own buttons and menus (hl).

Hides the full-screen button and removes the allowfullscreen attribute from the code.

Turns off the player's keyboard shortcuts, such as Space to play or pause and the arrow keys to seek.

Since a 2018 change, related videos can't be turned off completely. With this on, related videos come only from the same channel as this video.

Privacy, speed & accessibility

Switches the embed domain to www.youtube-nocookie.com. Views in this mode don't influence the viewer's recommendations on YouTube.

Waits to load the player until it is about to scroll into view, so the rest of the page loads faster.

The name screen readers announce. A descriptive name such as "How to set up X (YouTube video)" helps the most. If left blank, "YouTube video" is used.

Preview

Enter a YouTube URL to see the actual player here.

The preview uses the real YouTube player. Whether autoplay works depends on your browser settings. Fixed sizes are shown at actual size; scroll inside the frame if they don't fit.

How to Use

1

Paste the video URL

Open the video on YouTube, copy the URL from the address bar or the Share button, and paste it into the input box. Shorts, live and playlist URLs, or a plain 11-character video ID, work too.

2

Choose playback and size options

Set the start and end time, autoplay, loop, captions and sizing (responsive or fixed). Every change shows up in the code and preview right away. If you are unsure, the defaults work fine.

3

Copy and paste the code

Click "Copy code" and paste it into the HTML of your blog or website. In WordPress, use a "Custom HTML" block. For a share link that starts at a certain time, use the "Timestamp link" tab.

About the YouTube Embed Code Generator

This tool creates the HTML (an iframe tag) that shows a YouTube video on your own blog or website. Beyond what YouTube's Share → Embed dialog offers, you can set an end time, loop, captions and the player language, disable keyboard controls, and use responsive sizing that never overflows on phones — just by ticking boxes. The iframe attributes match YouTube's official embed code, so you can use the result with confidence. Everything runs in your browser, and the URLs you enter are never sent to our server.

Features

  • More options than the official embedBesides the start time, set an end time, loop, captions and the player language, or hide the full-screen button and disable keyboard controls — options YouTube's Embed dialog doesn't offer.
  • Responsive code that fits any screenChoose a simple CSS aspect-ratio version or the classic div-wrapper version. Vertical 9:16 Shorts and a maximum width are supported too.
  • Live preview with the real playerThe preview updates shortly after each change, so you can check the start position and size on the spot.
  • Timestamp share linksCreate "start at 1:23" links in both the short youtu.be format and the standard format. Tracking parameters such as si= are removed automatically.
  • Rebuild your existing embed codePaste the embed code you already use and the tool reads its settings, such as the start time and autoplay, so you can rebuild it as responsive code.
  • Runs entirely in your browserAll code is generated in your browser. The URLs and settings you enter are never sent to our server.

Use Cases

  • Add a tutorial or product video to a blog post or announcement
  • Embed just the part of a long video you want people to see, with start and end times
  • Play a muted, looping mood video in the hero of a store site or landing page
  • Put videos on mobile-first pages without anything overflowing the screen
  • Send a "watch from 1:23" link on social media, by email or in a chat

Common YouTube embed parameters

Parameters go after the "?" in the embed URL as name=value pairs joined with "&". This tool writes them correctly when you tick the options.

ParameterWhat it does
start=83Starts playback at 83 seconds (1:23).
end=165Stops playback 165 seconds (2:45) from the beginning of the video.
autoplay=1Autoplays the video. In most browsers this only works together with mute=1.
mute=1Starts playback muted.
loop=1&playlist=IDLoops playback. For a single video, pass the same video ID in playlist.
controls=0Hides the player controls, such as the play button and seek bar.
cc_load_policy=1Shows captions by default.
cc_lang_pref=jaSets the preferred caption language (an ISO 639-1 code, for example).
hl=enSets the language of the player's buttons and menus.
fs=0Hides the full-screen button.
disablekb=1Disables the player's keyboard controls.
playsinline=1Plays inline on iPhone instead of switching to full screen.
rel=0Limits related videos to the same channel (it can't hide them).
videoseries?list=PL…Embeds a playlist.
modestbranding=1 / showinfo=0Retired by YouTube and no longer have any effect (modestbranding since 2023, showinfo since 2018).

FAQ

I turned on autoplay, but the video doesn't start by itself. Why?
Major browsers such as Chrome, Safari and Edge have autoplay policies that usually block videos from playing with sound on their own. That is why this tool turns on Mute automatically when you enable autoplay. On iPhone, autoplay may also require "Play inline on iPhone". Even muted autoplay can be blocked by power-saving (Low Power) modes or by browser settings. Note that YouTube Help says embedded videos that autoplay don't increase the view count.
How do I make a video loop?
Turn on "Loop". To loop a single embedded video, YouTube's official documentation says to set loop=1 and pass the same video ID in the playlist parameter, and this tool writes both for you. For an embedded playlist, loop=1 alone repeats the whole list. When loop is combined with a start or end time, later loops may play from the beginning of the video instead of repeating only that range. To repeat a specific section reliably, use the YouTube Repeat Player.
Can rel=0 hide related videos?
Not anymore. Since a change YouTube made in 2018, rel=0 no longer hides related videos; instead, it limits them to videos from the same channel as the one that was played. There is no parameter that removes related videos completely. If you embed your own videos, turning on "Limit related videos to the same channel" keeps other channels' videos out of the related videos.
What is privacy-enhanced mode (youtube-nocookie.com)?
It changes the embed domain from www.youtube.com to www.youtube-nocookie.com. According to YouTube Help, views in this mode are not used to personalize the viewer's experience on YouTube, such as recommendations, and any ads shown are non-personalized. It does not guarantee that no cookies or similar storage are used at all, and the page still connects to YouTube's servers when it loads. It is a common choice for sites that describe third-party services in their privacy policy.
How do I add the code to WordPress?
In the block editor (Gutenberg), click the "+" button, add a "Custom HTML" block and paste the code. Use "Preview" at the top of the block to check how it looks. In the Classic Editor, switch to the "Text" tab before pasting. For users without the Administrator or Editor role (Authors and Contributors), and on multisite installations, iframes may be removed when the post is saved. If the video doesn't appear, check user roles and security plugin settings as well.
The video overflows or looks broken on phones. What should I do?
Choose "Responsive (recommended)". It makes the video as wide as its container (width:100%) and sets the height from the aspect ratio with CSS aspect-ratio, so it fits both phones and desktops. If your theme breaks the layout, try the "classic div wrapper". Fixed sizes such as 560×315 can overflow narrow phone screens and cause horizontal scrolling. If the video gets too large on desktops, set a max width.
How do I set the start and end times?
Enter h:mm:ss or m:ss (such as 1:23 or 0:01:23), plain seconds (83), or 1m23s. The code uses seconds, such as start=83. The end time is measured from the beginning of the video — not from the start time — and playback stops there. If you paste a URL that already contains a time, such as t=83, it is filled in as the start time automatically.
The embedded video doesn't show up or shows an error. What should I check?
Check the following: (1) The owner has disabled embedding (the player shows a message such as "Video unavailable"). (2) The video can't be played when embedded, for example because it is private, deleted or age-restricted. (3) Adding referrerpolicy="no-referrer" to the iframe, or sending no referrer site-wide, can cause YouTube errors such as error 153. This tool uses referrerpolicy="strict-origin-when-cross-origin", the same as YouTube's official code. (4) Make sure your CMS doesn't strip iframes, and that security plugins or a Content Security Policy (CSP) allow youtube.com (or youtube-nocookie.com in privacy-enhanced mode).
Can I embed Shorts or playlists?
Yes. When you paste a Shorts URL (/shorts/), it is converted to the standard embed format and switched to the vertical 9:16 ratio. Because a vertical video stretched to full width gets very tall, a max width of 360 px is filled in automatically. When you paste a playlist URL (list=), the tool creates a playlist embed (videoseries) that plays the videos in order. For a URL that contains both a video and a playlist, turn on "Embed as a playlist" to play the list starting from that video.