TubeMind

YouTube Embed Code Generator for Videos and Shorts

Paste a YouTube video, Shorts or playlist link and get embed code that works: responsive or a fixed size, start and end time (even from the link itself), autoplay, loop, captions in your viewers’ language, privacy-enhanced mode and related videos from your own channel only. A live preview shows exactly what your visitors will see.

Quick answer: to embed a YouTube video, paste its link into this free YouTube embed code generator, pick your options and copy the code into your site's HTML. You get a responsive iframe that fills the page width, a 9:16 box for Shorts and a playlist player for playlist links, built only from YouTube's documented player settings.

What this YouTube embed code generator does

An embed code is a small piece of HTML, called an iframe, that shows the YouTube player inside your own web page. Your visitor watches the video without leaving your site, and the view still belongs to the video on YouTube. This tool writes that code for you. You paste a link, tick the options you want, and copy the result.

It is for anyone who puts videos on a website: bloggers who add a video to a post, creators who show their latest upload on a personal site, teachers who add a clip to a course page, and shop owners who show a product video. I have been on YouTube since 2018, and embedding my own videos in my own posts is one of the oldest habits I have. I built TubeMind, and this generator is the version of the embed box I wanted: one place to set every option that still works.

The tool runs fully in your browser. Nothing is sent to our server, there is no sign-up and there is no limit on how many codes you make.

What it adds to YouTube's own Share, Embed button

YouTube already gives you embed code. Open a video, click Share, then Embed, and you get an iframe with a fixed size of 560 by 315 pixels, a "Start at" box and a privacy-enhanced mode box. That is fine for a quick paste on a desktop page. It falls short in a few common cases.

NeedShare, Embed in YouTubeThis generator
Fits phones and wide screensFixed size onlyResponsive by default, or one of four fixed sizes
Shorts in a vertical boxNo vertical option9:16 box, detected from the link or picked under Size
Play only part of a videoStart time onlyStart and end time
Loop, captions, inline on iPhoneEdit the code by handTick a box
Live preview before you pasteSmall previewFull preview with your options

In plain words: if your site has a narrow phone layout, or you embed Shorts, or you want a clip that stops at a set second, the Share box makes you edit the HTML yourself. Say you run a recipe blog and want only the 40 seconds where the sauce is made. In YouTube you can set the start, but you would have to type the end parameter into the code by hand. Here you type both times and copy.

How to use it, step by step

  1. Paste a link. A normal watch link, a youtu.be short link, a Shorts link, a live link, an embed link, a bare 11 character video ID or a playlist link all work. The tool tells you what it detected: Video (16:9), Shorts (9:16), Vertical (9:16) when you picked it under Size, Playlist, or Video in a playlist.
  2. Set the times if you need them. Start and end accept 90, 1:30 or 1m30s. If the link already has a time in it (t= or start=), that becomes the start time and the tool says so under the code.
  3. Add a title for screen readers. This fills the iframe's title, which screen readers read aloud. "YouTube video" is the default, but a real description such as "How to fold a shirt in 10 seconds" helps blind visitors.
  4. Choose a size. Responsive fills the width it is given. The fixed options are 560 by 315, 640 by 360, 853 by 480 and 1280 by 720. Vertical 9:16 puts the video in the tall box used for Shorts.
  5. Choose captions. Viewer's choice leaves captions off unless the viewer turns them on. On by default shows them at once. You can also pick a language: English, Urdu, Hindi, Arabic, Spanish, French, German, Portuguese, Indonesian or Turkish.
  6. Tick the options. Autoplay (muted), Mute, Loop, Hide controls, Privacy-enhanced, Related videos from this channel only, No fullscreen button, Play inline on iPhone, Disable keyboard and White progress bar.
  7. Check the preview, then copy. Press Generate code, watch the preview, then use Copy embed code for the full HTML or Copy embed URL if your site builder only asks for a link.

Three options start ticked because they suit most sites: privacy-enhanced mode, related videos from the same channel, and inline play on iPhone. Untick any of them if you have a reason.

How the code is built

Every option maps to one setting that YouTube documents on its embedded player parameters page. The tool adds these settings to the end of the embed address, after a question mark. The table shows what each option writes.

OptionSetting addedWhat it does
Start and endstart, endPlays from one second to another
Autoplay (muted)autoplay=1 and mute=1Starts on page load without sound
Mutemute=1Starts without sound, waits for a click
Looploop=1, plus playlist=the video IDRepeats the video or the playlist
Hide controlscontrols=0Removes the control bar
Captionscc_load_policy=1, cc_lang_prefShows captions by default, in a set language
Related from this channelrel=0End screen suggestions come from the same channel
No fullscreen buttonfs=0Hides the fullscreen button
Play inline on iPhoneplaysinline=1Plays inside the page on iOS
Disable keyboarddisablekb=1The player ignores keyboard keys
White progress barcolor=whiteMakes the progress bar white
Privacy-enhancedyoutube-nocookie.com hostChanges the address the player loads from

Here is how to read the table. The middle column is the exact text the tool adds. If you tick Loop and No fullscreen button for a single video, the end of the address reads loop=1, playlist, the video ID, and fs=0. One note: mute is not on YouTube's official parameter list. The player accepts it today, and it is what lets autoplay work, but YouTube could change it without notice.

Times are turned into whole seconds, because YouTube's start and end take seconds only. 1:30 becomes 90, 1h2m5s becomes 3725, and a plain 75 stays 75. If the end time is not after the start time, the tool stops and asks you to fix it rather than write code that would not play.

Every code also carries a few fixed parts: frameborder="0", allowfullscreen, an allow list (autoplay, encrypted-media, picture-in-picture, clipboard-write, web-share and the motion sensors), loading="lazy" and referrerpolicy="strict-origin-when-cross-origin". The last two matter, and are explained further down.

Responsive and fixed sizes

With Responsive, the iframe sits inside a box whose height is a fixed share of its width. For a normal video the box height is 56.25% of the width, which is 9 divided by 16, so the shape is always 16:9. For Shorts it is 177.78%, which is 16 divided by 9, so the shape is 9:16. The Shorts box is also capped at 360 pixels wide, so a vertical video does not fill a whole desktop screen.

An example: on a phone where the content column is 360 pixels wide, a responsive 16:9 video is 360 by about 203 pixels. On a laptop column of 800 pixels it becomes 800 by 450. The same code works for both. A fixed 560 by 315 iframe, by contrast, would spill off the side of that 360 pixel phone screen.

Fixed sizes write plain width and height on the iframe. They apply to normal videos and playlists. Shorts always use the responsive vertical box, because a fixed 16:9 size would squash a vertical video.

A worked example: embedding a video

Say you paste https://youtu.be/VIDEO_ID?t=95, leave Start empty, type 2:40 in End, pick On, in Urdu for captions, and keep the three default options ticked. The tool reads t=95 from the link, so the start is 95 seconds. The end, 2:40, becomes 160 seconds. The note under the code says "Start time 95 s was taken from your link." The embed address becomes:

https://www.youtube-nocookie.com/embed/VIDEO_ID?start=95&end=160&rel=0&playsinline=1&cc_load_policy=1&cc_lang_pref=ur

Read it from left to right. The nocookie host is the privacy-enhanced mode. start=95 and end=160 play a 65 second clip, from 1:35 to 2:40. rel=0 keeps end suggestions on the same channel. playsinline=1 keeps the video inside the page on an iPhone. The last two settings turn captions on and ask for Urdu ones. If the video has no Urdu captions, the viewer can still pick another track from the player.

One detail from YouTube's documentation that trips people up: the end time is counted from the start of the video, not from your start time. So to play from 1:35 to 2:40 you type 2:40 as the end, not 1:05. Also, the player may begin up to about two seconds before your start time, because it jumps to the nearest keyframe.

YouTube's current rules for embeds

These are the rules that matter, checked against YouTube's own pages in November 2026: the Embed videos and playlists help page and the player parameters reference.

  • Autoplayed embeds do not add views. YouTube's help page says "Embedded videos that are autoplayed don't increment video views." If views matter, let visitors press play.
  • Related videos cannot be turned off. Since 2018, rel=0 only limits end suggestions to the same channel as the video that was played.
  • The YouTube logo stays. The old modestbranding setting is deprecated and has no effect, so this tool does not offer it. The showinfo setting, which once hid the title, has been ignored since 2018.
  • Minimum size is 200 by 200 pixels. YouTube asks that the player is at least that big, and suggests at least 480 by 270 for a 16:9 player.
  • Loop needs a playlist value. For one video, YouTube needs loop=1 plus the same video ID as a playlist. The tool adds both.
  • A referrer is required. YouTube's help page says embedders must send an HTTP referrer. Without it, playback can be blocked with error 153.
  • Privacy-enhanced mode is for websites. YouTube says views in this mode do not shape the viewer's YouTube recommendations, ads shown in it are non-personalized, and the mode is not available inside apps.

Autoplay, mute and views

Most browsers block video that starts with sound until the visitor has clicked or tapped on the page. That is why Autoplay in this tool always adds mute. A muted autoplay usually starts; an autoplay with sound usually does not.

Before you tick it, think about what the video is for. A looping, silent product clip at the top of a shop page is a good fit for autoplay. A tutorial you want counted as a view is not, because of the rule above. Embedded views from a visitor who presses play do count, and they show in YouTube Analytics under the External traffic source, which YouTube describes in its reach report help page as "Traffic from websites and apps that have your YouTube video embedded or linked to." If you want to know more about how YouTube filters views, my guide on how to check if YouTube views are fake explains it.

Embedding Shorts

A Shorts link looks like youtube.com/shorts/ID. That address cannot go into an iframe as it is. The tool takes the ID out and builds a normal embed address, then puts it in the 9:16 box. The Short plays in the standard YouTube player, so viewers get play controls rather than the swipe feed of the Shorts app.

The vertical box is chosen when the link contains /shorts/. If you paste a Short as a watch link or a youtu.be link, the tool cannot tell it is vertical, so pick Vertical 9:16 under Size, or copy the link from the Shorts player.

Embedding a playlist

Paste any link with list= in it. If the link has only a playlist, the code loads YouTube's playlist player and plays the videos in order, with a playlist button for viewers to jump around. If the link has a video and a playlist, the embed starts at that video and carries on through the list. With Loop ticked, the whole playlist repeats. To know how long a playlist takes to watch before you embed it, use the playlist length calculator.

Privacy-enhanced mode and cookie consent

Privacy-enhanced mode loads the player from youtube-nocookie.com instead of youtube.com. It is on by default here because it is the more private choice and costs nothing.

It is worth being clear about what it does not do. YouTube describes it as limiting how embedded views affect the viewer's own YouTube experience and ads. It does not promise that no data is stored once the visitor plays the video. If your site must ask for consent before any third party content loads, privacy-enhanced mode alone may not be enough; you may need your consent tool to block the iframe until the visitor agrees. Ask whoever handles privacy for your site.

Why an embed shows "Video unavailable" or error 153

  • Embedding is off. The owner can untick "Allow embedding" in YouTube Studio, under the video's details. Only they can change it. The preview in this tool will show the same error, so you know before you paste.
  • Age-restricted, private or removed video. YouTube says age-restricted videos cannot be watched on most third party sites; viewers are sent to YouTube instead.
  • No referrer. Error 153 means the player did not get a referrer. Our code includes referrerpolicy="strict-origin-when-cross-origin" so the browser sends one. If you still see 153, check that your site or a plugin is not removing referrers with a strict setting such as no-referrer.
  • Opened directly. Pasting the embed URL into the address bar often gives the same error, because there is no page around it. Test the code inside a real page.

Keep your page fast

Each embed loads the YouTube player, which is heavy compared with the rest of a blog page. The code from this tool uses loading="lazy", so the browser waits until the visitor scrolls near the video before loading the player. That helps most when the video sits lower on the page.

A few habits help more. Put only one embed above the fold. If a post lists many videos, embed the main one and link the rest with a thumbnail image. You can get thumbnails in every size from the thumbnail downloader, and the right dimensions are covered in the YouTube thumbnail size guide. To collect the IDs of many videos at once, paste their links into the video ID extractor.

Where to paste the code

In WordPress, add a Custom HTML block and paste the code. In Wix, Squarespace, Shopify and Webflow, use the platform's embed or custom code element. In a plain HTML file, paste it where the video should appear. If a builder only accepts a video URL, use Copy embed URL instead of the full code. The code contains no script, only an iframe and, for responsive sizes, one wrapper div with inline styles, so it works on any builder that allows iframes.

What trips people up with embedding a video

  • Turning on autoplay for a video whose views you care about. Autoplayed embeds do not count.
  • Typing the end time as a length. End is a point in the video, counted from 0:00.
  • Hiding controls on a long video. Viewers cannot pause or seek, and many will leave.
  • Using a fixed 1280 by 720 size in a narrow blog column. It overflows on most screens; use Responsive.
  • Leaving the title as "YouTube video" on a page with several embeds. Screen reader users hear the same name for each one.
  • Disabling the keyboard. People who cannot use a mouse lose the only way to control the player.

What to take from the embed code

Above the code, the tool shows what it detected and the start and end in seconds. Check that line first: if it says Video (16:9) for a Short, paste the /shorts/ link or pick Vertical 9:16 under Size. Then play the preview. What you see there is what your visitors will see, including any embedding block from the owner. Under the code, short notes explain side effects, such as autoplay not adding views or loop repeating a whole playlist.

After you paste the code on your site, open the page on a phone and a computer. Then link to a moment instead of embedding when that fits better: the timestamp link generator makes a plain link that opens at a set time. If you embed your own videos, chapters help visitors jump around inside the player; the chapters generator drafts them from your video.

Ways to get embed code compared

MethodGood forWeak spot
Share, Embed in YouTubeA quick fixed size embed with a start timeNo responsive size, no end time, no Shorts shape
Writing the iframe by handDevelopers who know every parameterEasy to use deprecated settings or forget the loop playlist
CMS video block, such as WordPress's YouTube blockPasting a link with no optionsFew or no player options
This generatorEvery working option, with a previewOnly the options listed above, no click to load facade

For most people the choice is simple. If a plain video in a CMS block looks fine, use that. If you need a clip, a Short, captions in a set language, or a layout that fits phones, a generator saves you from editing parameters by hand.

Limits of the embed generator

  • It cannot embed a video whose owner turned embedding off, or change any setting on YouTube's side.
  • Shorts are detected only from /shorts/ links. For a Short pasted as a watch or youtu.be link, pick Vertical 9:16 under Size.
  • Fixed sizes are the four presets; there is no custom width and height box yet. You can edit the numbers in the code after copying.
  • Caption languages are limited to the ten listed. The captions show only if the video has a track in that language.
  • If your link has a time in it, a start of 0 typed in the Start box does not override it. Remove t= from the link to start at 0:00.
  • It does not make a whole channel feed or a gallery. For a channel, link people with the subscribe link generator.

Urdu / Hindi mein: YouTube video website par kaise lagayein?

Video, Shorts ya playlist ka link paste karein, options chunein aur Generate code dabayein. Phir code copy kar ke apni website ke HTML mein laga dein, jaise WordPress mein Custom HTML block. Responsive size phone aur computer dono par sahi chalta hai. Shorts ke liye tool khud 9:16 box banata hai, aur playlist link par poori playlist chalti hai. Link mein time ho to video wahin se shuru hogi, aur end time 0:00 se gina jata hai. Autoplay hamesha muted hota hai, aur YouTube ke mutabiq autoplay wali embedded videos ke views nahi gine jaate. Agar "Video unavailable" aaye to ho sakta hai owner ne embedding band ki ho.

Questions

How do I get the embed code for a YouTube video?

Paste the video link into this generator, choose your options and press Generate code. Copy the code and paste it into your page's HTML. You can also use Share, then Embed, on YouTube for a basic fixed size code.

Is this YouTube embed code generator free?

Yes. It is free, needs no sign-up and runs in your browser, so there is no limit on how many codes you make.

How do I make a YouTube embed responsive?

Keep Size on Responsive. The iframe sits in a box that keeps a 16:9 shape (9:16 for Shorts) and fills the width of your page on any screen.

How do I embed a YouTube video at a specific time?

Type the start time as 90, 1:30 or 1m30s, or paste a link that already has t= in it. The tool turns it into seconds, which is what YouTube's start setting needs.

Can I embed only part of a YouTube video?

Yes. Set a start and an end time. The end is counted from 0:00 of the video, not from your start time.

Why is my embedded YouTube video not autoplaying?

Browsers block video that starts with sound. Autoplay in this tool is always muted, which most browsers allow.

Do autoplayed embeds count as views?

No. YouTube's help page says embedded videos that are autoplayed don't increment video views. Views from visitors who press play do count.

Do embedded views count on YouTube?

Yes, when the visitor presses play. They show in YouTube Analytics under the External traffic source.

How do I loop an embedded YouTube video?

Tick Loop. For a single video YouTube needs loop=1 plus the same video ID as a playlist, and the tool adds both.

Can I embed a YouTube Short?

Yes. Paste the youtube.com/shorts/ link and the code uses a vertical 9:16 box that plays the Short in the normal YouTube player.

How do I embed a YouTube playlist?

Paste a link with list= in it. You get YouTube's playlist player, which plays the videos in order.

Can I turn off related videos in a YouTube embed?

Not completely. Since 2018, the rel=0 setting only makes end suggestions come from the same channel.

Can I hide the YouTube logo or title in an embed?

No. The modestbranding and showinfo settings no longer have any effect, so this tool does not offer them.

How do I show captions by default?

Pick On by default in the Captions box, or pick a language. Captions appear only if the video has a track in that language.

What is YouTube privacy-enhanced mode?

It loads the player from youtube-nocookie.com. YouTube says views in this mode do not shape the viewer's YouTube recommendations and ads shown are non-personalized.

Does privacy-enhanced mode make my embed GDPR compliant?

Not on its own. If your site must get consent before third party content loads, use your consent tool to block the iframe until the visitor agrees.

Why does my embed say Video unavailable or error 153?

The owner may have turned off embedding, the video may be private or age-restricted, or the page did not send a referrer. Our code includes a referrer policy to prevent error 153.

Can I embed someone else's YouTube video?

Yes, if the owner allows embedding. The video stays on YouTube and the view counts for the owner.

What size should a YouTube embed be?

Responsive is best for most sites. If you need a fixed size, 560 by 315 or 640 by 360 suit most columns, and YouTube asks for at least 200 by 200 pixels.

YouTube video website par kaise embed karein?

Link paste karein, options chunein aur code copy kar ke website ke HTML mein laga dein. Shorts aur playlist bhi chalte hain, aur autoplay hamesha muted hota hai.

Can I embed a whole YouTube channel?

Not with this tool. It embeds one video or one playlist. To show a set of videos from your channel, put them in a public playlist and paste the playlist link here.

Can I control the embedded player with JavaScript?

Not with the code this tool makes. YouTube's IFrame Player API lets developers play, pause and track the player from their own code, and it needs enablejsapi=1 plus your site's origin in the embed link, so add those yourself if you need them.

Related tools

Ask about this page in ChatGPT · Claude · Perplexity

All 74 free YouTube tools