YouTube Embed Code Generator – Free Responsive iFrame Builder (2025)
Free online tool

YouTube Embed Code
Generator

Generate custom responsive YouTube iframe embed codes in seconds — with full control over autoplay, loop, mute, start time, privacy mode, and more. No signup required.

Fully responsive Privacy-safe (no-cookie mode) Supports playlists & Shorts Zero cost, no account

Customize your embed

Adjust dimensions, playback behavior, and privacy settings below — your code and preview update instantly.

Video source
Paste any YouTube URL — watch, short, or youtu.be links all work
Embeds the full playlist with a player that cycles through all videos
Shorts are embedded in portrait (9:16) aspect ratio automatically
Dimensions
Playback options
Autoplay
Starts playing when the page loads (requires Mute)
Mute
Start video with no sound
Loop
Restart video after it ends
Hide controls
Remove the player control bar
Hide fullscreen button
Disables the fullscreen option in the player
Privacy & appearance
Privacy-enhanced mode GDPR
Uses youtube-nocookie.com — no cookies until play
Responsive (recommended)
Wraps in a CSS container that scales to any screen
Hide related videos
Shows only your channel's related videos at end
Hide YouTube branding
Removes YouTube logo from control bar (modest branding)
Current: 0px
Live preview
preview
Paste a YouTube URL to preview
Generated embed code
<!-- Paste a YouTube URL above to generate your embed code -->
Paste this code into your website's HTML where you want the video to appear. For WordPress, switch to the HTML / Text editor block.
Why use this tool

Everything you need to embed YouTube videos

The most complete free YouTube embed generator — built for developers, bloggers, and marketers who need full control over their video embeds.

Fully responsive embeds
CSS wrapper keeps your 16:9 (or custom) ratio on every device — from desktop to mobile — automatically.
Privacy-enhanced mode
Uses youtube-nocookie.com — YouTube sets no cookies until the visitor actually clicks play. Essential for GDPR compliance.
Start & end time
Embed a specific segment of any video. Ideal for tutorials, product demos, or highlighting a specific moment.
Playlist support
Embed an entire YouTube playlist. The player automatically loads the next video in the queue when one ends.
Autoplay & mute control
Set videos to play automatically on page load (with mute — browsers require it) or use mute standalone for silent background video.
Loop playback
Seamlessly restart the video once it finishes — perfect for background videos, ambience loops, or demo reels.
YouTube Shorts embeds
Embeds Shorts in a portrait 9:16 container so they display correctly on your website — no manual CSS needed.
Instant live preview
See exactly how your embed will look as you adjust settings — before you copy a single line of code.
How it works

Embed a YouTube video in 3 steps

No coding knowledge needed. Works with any website, WordPress, Webflow, Wix, Squarespace, or plain HTML.

1
Paste your YouTube URL
Copy the URL from any YouTube video, playlist, or Shorts page and paste it into the generator above. Any URL format works — youtube.com/watch?v=, youtu.be/, or just the video ID.
2
Customise your options
Set your dimensions, toggle autoplay, mute, loop, privacy mode, and any other parameters. The live preview updates instantly so you can see exactly how the embed will look.
3
Copy and paste the code
Click Copy, then paste into your website's HTML. In WordPress, use a Custom HTML block. In Webflow, use an Embed element. In Squarespace, use a Code block.

How to make a YouTube embed responsive

By default, YouTube iframes have fixed pixel dimensions. On mobile devices, this causes the video to overflow or be cut off. The Responsive toggle in this generator wraps your iframe in a CSS container:

  • The wrapper uses padding-bottom: 56.25% (for 16:9) to maintain aspect ratio
  • The iframe inside is absolutely positioned to fill the container
  • The result scales perfectly from 320px mobile to 4K desktop

WordPress tip

In the Gutenberg editor, add a Custom HTML block and paste the full embed code. For the Classic editor, switch to the HTML tab before pasting.

What does youtube-nocookie.com do?

When you use youtube-nocookie.com instead of youtube.com in your embed URL, YouTube does not set any tracking cookies on your visitor's browser until they actually click play. This is important if your site has European visitors and you want to stay compliant with GDPR without a complex cookie consent setup just for embedded videos.

Common questions

Frequently asked questions

Everything you need to know about YouTube embed codes.

Paste your YouTube video URL into the generator above, customise options like width, autoplay, and responsiveness, then copy the generated iframe code and paste it into your website's HTML. In WordPress, use a Custom HTML block. In Webflow, use an Embed element.
A YouTube iframe embed is an HTML <iframe> element that loads the YouTube player inside your webpage. Visitors can watch the video without leaving your site. YouTube generates basic iframe code via their Share button, but this generator lets you customise far more parameters — responsiveness, privacy mode, start/end times, and more.
The most common causes are: (1) The video owner has disabled embedding — check the video settings on YouTube; (2) Autoplay is blocked by the browser — autoplay requires the mute parameter; (3) The URL is malformed — use this generator to produce a clean, tested embed URL; (4) A Content Security Policy on your server is blocking iframes — check your server headers.
Enable both Autoplay and Mute in the generator above. Modern browsers (Chrome, Firefox, Safari) block autoplaying videos with sound — they will only autoplay if the video is muted. Adding &autoplay=1&mute=1 to the iframe src handles this. The generator does this automatically when you enable Autoplay.
youtube-nocookie.com is YouTube's privacy-enhanced embed domain. When you embed using this domain, YouTube sets no cookies on your visitor's browser until they click play. This is recommended for any site with EU visitors (GDPR) and it is enabled by default in this generator. The video still works identically for end users.
Yes. Click the Playlist tab in the generator above and paste in your playlist URL. The embed will show the full playlist with navigation controls so visitors can browse all videos. The first video plays automatically (with mute if autoplay is needed).

The complete guide to YouTube embed codes

Embedding YouTube videos on your website is one of the most effective ways to enrich your content without increasing your hosting costs. Instead of uploading video files to your own server, you let YouTube handle the delivery — giving you access to YouTube's global CDN, adaptive bitrate streaming, and automatic format optimisation for free.

Understanding the YouTube embed URL structure

A standard YouTube embed URL looks like this:

https://www.youtube-nocookie.com/embed/VIDEO_ID?rel=0&autoplay=1&mute=1

The part after the ? is the query string, where parameters control behaviour. Common parameters include:

  • autoplay=1 — starts playing on load (requires mute=1 in modern browsers)
  • mute=1 — starts with sound off
  • loop=1 — repeats the video (also requires playlist=VIDEO_ID for single videos)
  • controls=0 — hides the player control bar
  • rel=0 — shows only related videos from the same channel at end
  • start=30 — begins playback at 30 seconds
  • end=120 — stops playback at 120 seconds
  • fs=0 — hides the fullscreen button
  • modestbranding=1 — removes the YouTube logo from the control bar

Responsive YouTube embeds: the CSS technique

The standard approach to making a YouTube embed responsive is the aspect-ratio padding trick. Here is what the generated responsive code looks like:

.video-responsive { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; }

56.25% is simply 9 ÷ 16 — the height as a percentage of width for a 16:9 video. For 4:3 video, use 75%. The iframe inside is then positioned absolutely to fill this container exactly. Modern browsers also support the CSS aspect-ratio property as an alternative approach.

YouTube embeds and page speed

Embedding YouTube videos can slow your page because the YouTube player loads several megabytes of JavaScript even if the visitor never plays the video. Advanced techniques to solve this include using a poster image with a play button overlay, and only loading the YouTube iframe when the visitor clicks — this is called a "lazy YouTube embed" or "facade pattern" and is recommended by Google's Lighthouse performance tool.

Embedding YouTube videos in WordPress

In the Gutenberg block editor (WordPress 5+), add a Custom HTML block and paste your generated embed code. Do not use the standard Video or YouTube block if you need custom parameters — those blocks do not support advanced options like nocookie mode or start times. In the Classic Editor, switch the editor to Text mode and paste the code there; never paste embed code in the Visual editor.

Scroll to Top