ToolNimba

๐Ÿ“บ YouTube Embed Code Generator

Shihab Mia By Shihab Mia ยท Updated 2026-06-27

Live preview

Paste a YouTube URL above. The preview and embed code update automatically.

This YouTube embed code generator turns any video URL into ready-to-paste iframe embed code in seconds. Paste a YouTube link, choose a fixed width and height or a responsive 16:9 layout, then toggle autoplay, mute, loop, hidden controls or a custom start time. The live preview shows exactly how the player will look, and one click copies the embed youtube video code for your site.

What is the YouTube Embed Code Generator?

A YouTube embed is an iframe element that loads the YouTube player from youtube.com inside your own web page. Instead of sending visitors away to watch a clip, you keep them on your page while the video streams from YouTube servers, which means no bandwidth or storage cost for you. The embed code is just a small block of HTML, and this YouTube embed code generator writes that block for you so you do not have to remember the exact syntax or the long list of player parameters.

Every YouTube video has an 11-character video ID. In a normal watch link like youtube.com/watch?v=dQw4w9WgXcQ the ID is the part after v=. Short links use youtu.be/dQw4w9WgXcQ, Shorts use youtube.com/shorts/ID, and an existing embed uses youtube.com/embed/ID. The generator reads the ID out of any of these formats automatically, so you can paste whatever link you have on hand and it still works. The embed itself always points at https://www.youtube.com/embed/ plus that ID.

The player is configured with query parameters added to the embed URL. Autoplay (autoplay=1) starts the video as soon as the page loads, mute (mute=1) is required for autoplay to work in most modern browsers, loop (loop=1 together with playlist=ID) replays the clip when it ends, start sets the number of seconds to begin playback at, and controls=0 hides the play bar for a cleaner look. The generator assembles these for you and shows the finished embed youtube video code in the box below the preview.

There are two common layouts. A fixed-size embed uses width and height attributes in pixels, which is fine when you know the exact space you have. A responsive YouTube embed wraps the iframe in a padded container that holds a 16:9 aspect ratio, so the video scales to fill its column on desktop and shrinks neatly on phones without leaving black bars or overflowing the screen. For most blogs and modern themes the responsive option is the safer default, and this is the mode the YouTube embed code generator selects out of the box.

The code produced here is plain, standards-based HTML. It uses the standard allow attribute (covering fullscreen, picture-in-picture and encrypted media), allowfullscreen so viewers can expand the player, and a referrerpolicy that matches what YouTube ships in its own Share menu. You can paste it into a raw HTML block in WordPress, Webflow, Ghost, a static site, an email template that supports iframes, or any CMS that accepts custom HTML. Nothing is uploaded and nothing leaves your browser, so the tool is private and works offline once loaded.

When to use it

  • Adding a tutorial or product demo video to a blog post or landing page without sending readers off to YouTube.
  • Building a responsive YouTube embed that scales cleanly on mobile, tablet and desktop layouts.
  • Creating an autoplay, muted hero video for the top of a marketing page.
  • Linking a viewer to a specific moment by setting a custom start time in seconds.
  • Generating a clean, controls-hidden background-style player for a portfolio or kiosk screen.
  • Quickly grabbing valid iframe code when a CMS strips the player you copied from elsewhere.

How to use the YouTube Embed Code Generator

  1. Paste your YouTube link (watch, youtu.be, Shorts or embed format) or the bare 11-character video ID into the URL box.
  2. Choose a layout: leave Responsive ticked for a 16:9 scaling embed, or untick it to enter a fixed width and height in pixels.
  3. Toggle the options you want: autoplay, mute, loop, hide controls, or set a start time in seconds.
  4. Watch the live preview to confirm the player looks and behaves the way you expect.
  5. Click Copy code to copy the iframe embed code to your clipboard.
  6. Paste the code into a raw HTML block on your page, then publish.

Formula & method

Embed URL: https://www.youtube.com/embed/<VIDEO_ID>?autoplay=1&mute=1&loop=1&playlist=<VIDEO_ID>&start=<seconds>&controls=0. Wrap the iframe in a position:relative; padding-bottom:56.25% container for a responsive 16:9 embed, or use fixed width and height attributes for a set size. Only the parameters you enable are added.
How the YouTube embed code is built1. Paste URLwatch?v= / youtu.be2. Extract IDdQw4w9WgXcQ3. Add optionsautoplay, start, loophttps://www.youtube.com/embed/dQw4w9WgXcQ?autoplay=1&mute=1&start=90the embed URL the iframe loads<iframe src="..." allowfullscreen></iframe>copy and paste into your page

Worked examples

A basic responsive embed from a standard watch link.

  1. Paste https://www.youtube.com/watch?v=dQw4w9WgXcQ into the URL box.
  2. Leave Responsive ticked and all other options off.
  3. The tool extracts the ID dQw4w9WgXcQ and builds a 16:9 wrapper.

Result: A div with padding-bottom:56.25% holding an iframe with src="https://www.youtube.com/embed/dQw4w9WgXcQ" that fills its container.

A muted autoplay hero video at a fixed size.

  1. Paste a youtu.be/dQw4w9WgXcQ short link.
  2. Untick Responsive and set width 560, height 315.
  3. Tick Autoplay and Mute (autoplay needs mute in most browsers).

Result: <iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ?autoplay=1&amp;mute=1" ...></iframe>

A clip that starts 90 seconds in with the controls hidden.

  1. Paste the video URL or ID.
  2. Set Start time to 90 and choose Hide controls.
  3. Keep the responsive layout for clean scaling.

Result: The src becomes https://www.youtube.com/embed/<ID>?start=90&amp;controls=0, so playback begins at 1:30 with no control bar.

YouTube embed parameters this generator can add

OptionParameter addedWhat it does
Autoplayautoplay=1Starts the video automatically on page load (usually needs mute=1).
Mutemute=1Loads the player muted; required for reliable autoplay.
Looploop=1 and playlist=IDReplays the clip when it ends (a single video needs playlist set to its own ID).
Start timestart=secondsBegins playback at the given number of seconds.
Hide controlscontrols=0Removes the bottom control bar for a cleaner player.

Supported URL formats and where the video ID sits

FormatExampleID location
Watch linkyoutube.com/watch?v=dQw4w9WgXcQAfter v=
Short linkyoutu.be/dQw4w9WgXcQAfter the slash
Shortsyoutube.com/shorts/dQw4w9WgXcQAfter /shorts/
Embed linkyoutube.com/embed/dQw4w9WgXcQAfter /embed/
Bare IDdQw4w9WgXcQThe whole string (11 characters)

Common mistakes to avoid

  • Expecting autoplay to work without mute. Chrome, Safari, Firefox and Edge block autoplay with sound. If you want the video to start on its own, tick both Autoplay and Mute, otherwise the browser will silently refuse to play it.
  • Trying to loop without a playlist parameter. A single video will not loop with loop=1 alone. YouTube requires playlist=VIDEO_ID set to the same ID for one video to repeat. This generator adds that for you when Loop is ticked.
  • Using watch?v= or youtu.be links directly in the iframe. The iframe src must use the /embed/ path, not a watch or short link. Pasting a watch URL straight into an iframe shows an error. The tool converts the link into the correct embed URL automatically.
  • Setting a fixed width that overflows on mobile. A hard-coded width like 800 can push past the screen on phones and break your layout. Use the Responsive option, or keep the width at or below your content column width, so the embed never overflows.
  • Pasting the embed into a visual editor that escapes the HTML. Many editors show the raw code as text instead of rendering it. Switch to the code, HTML or custom-HTML block of your CMS before pasting, or the iframe will appear as plain text on the page.

Glossary

Embed
Placing a YouTube player inside your own web page using an iframe, so the video plays without leaving your site.
iframe
An HTML element that loads another page (here, the YouTube player) inside a box on your page.
Video ID
The unique 11-character code that identifies a YouTube video, found after v= in a watch link.
Embed URL
The youtube.com/embed/ID address the iframe loads, with any player options added as query parameters.
Responsive embed
A layout that keeps a 16:9 aspect ratio and scales the player to fit any screen width.
Aspect ratio
The width-to-height proportion of the video; standard YouTube videos are 16:9, which equals 56.25 percent padding.
Query parameter
A name=value pair added after a ? in the URL, such as autoplay=1, that configures the player.
allowfullscreen
An iframe attribute that lets viewers expand the YouTube player to fill the screen.

Frequently asked questions

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

Paste the video URL into this YouTube embed code generator, pick your options, and click Copy code. You get a ready-to-paste iframe with no need to open YouTube. It works with watch links, youtu.be short links, Shorts and bare video IDs.

How do I embed a YouTube video in HTML?

Generate the iframe code here and paste it into a raw HTML block on your page. The code points at https://www.youtube.com/embed/ plus the video ID, which is exactly what is needed to embed a youtube video in html on any site that accepts custom HTML.

How do I make a responsive YouTube embed?

Leave the Responsive option ticked. The tool wraps the iframe in a container with padding-bottom:56.25 percent to hold a 16:9 ratio, so the player scales to its column on desktop and shrinks cleanly on mobile without black bars.

How do I make a YouTube video autoplay?

Tick Autoplay and Mute. Browsers block autoplay with sound, so the YouTube autoplay embed code only plays automatically when the player is muted. Both options are added to the embed URL for you.

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

Enter the number of seconds in the Start time field. The generator adds start= to the URL, so the youtube embed start time begins playback at that point, for example start=90 to begin at 1:30.

How do I loop a YouTube embed?

Tick Loop. A single video needs both loop=1 and playlist set to the same video ID to repeat, and the youtube embed loop option adds both automatically so the clip replays when it ends.

How do I hide the YouTube player controls?

Choose Hide controls in the dropdown. This adds controls=0 to the embed URL, which removes the bottom control bar for a cleaner look. Viewers can still click the video to pause or play.

Can I change the size of the embedded video?

Yes. Untick Responsive to enter an exact width and height in pixels for a fixed-size player, or keep Responsive on so the youtube iframe scales to its container. The default fixed size is 560 by 315.

Does this YouTube embed code generator work with youtu.be and Shorts links?

Yes. It reads the video ID from watch links, youtu.be short links, youtube.com/shorts links, existing /embed/ links and bare 11-character IDs, then builds the correct embed code from whichever you paste.

Is the embed code free and private?

Yes. The YouTube embed code generator runs entirely in your browser, so nothing is uploaded or stored. The code is free to use, and the video still streams directly from YouTube to your visitors.